Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. # encoding=utf-8
  3. import asyncio
  4. from utility import time_me, hello
  5. from run_ import run, create_task
  6. """
  7. filename: basic15.py
  8. description: as_completed
  9. License: GPL V2
  10. Author: 天使de眼睛
  11.  
  12. 除特别声明,所有代码均是 python3.6 在 iOS 环境下编写测试。
  13. """
  14.  
  15. asyncio.run = run
  16. asyncio.create_task = create_task
  17.  
  18. @time_me
  19. async def main():
  20. tasks = [asyncio.create_task(hello(1, 'Kitty')), asyncio.create_task(hello(2, 'Doggy')) ]
  21. for task in asyncio.as_completed(tasks):
  22. print(await task)
  23.  
  24.  
  25. if __name__ == '__main__':
  26. asyncio.run(main())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement