Advertisement
Atheuz

Untitled

May 30th, 2020
1,063
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.39 KB | None | 0 0
  1. import asyncio
  2.  
  3. async def task(n):
  4.     result = []
  5.     for i in range(1, n+1):
  6.         result.append((n, i))
  7.     return result
  8.  
  9. async def main():
  10.     awaitables = []
  11.     for k in range(1,10):
  12.         t = task(k)
  13.         awaitables.append(t)
  14.     results = await asyncio.gather(*awaitables)
  15.     for task_result in results:
  16.         print(task_result)
  17.  
  18. asyncio.run(main(), debug=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement