daily pastebin goal
81%
SHARE
TWEET

Untitled

a guest Mar 18th, 2019 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python3
  2. # encoding=utf-8
  3. import asyncio
  4. from utility import hello, time_me
  5. from run_ import run, create_task
  6. """
  7. filename: basic10.py
  8. description: gather with exception
  9.     if return_exeptions is set to true. then exception message will return as result
  10. License: GPL V2
  11. Author: 天使de眼睛
  12.  
  13. 除特别声明,所有代码均是 python3.6 在 iOS 环境下编写测试。
  14. """
  15.  
  16. asyncio.run = run
  17. asyncio.create_task = create_task
  18.  
  19. async def gather_tasks():
  20.     return await asyncio.gather(hello(2, 'Kitty', raise_exception=True), hello(1, 'Doggy'), return_exceptions=True)
  21.  
  22. @time_me
  23. def main():
  24.     kitty, doggy =  asyncio.run(gather_tasks())
  25.     print('Kitty returns:', kitty)
  26.     print('Doggy returns:', doggy)
  27.  
  28.  
  29. if __name__ == '__main__':
  30.     main()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top