Advertisement
Guest User

Untitled

a guest
May 21st, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. import asyncio
  2.  
  3.  
  4. async def test_1(a, b, c):
  5. await a
  6. await b
  7. await c
  8.  
  9. async def test_2():
  10. await asyncio.sleep(10)
  11. await asyncio.sleep(10)
  12. await asyncio.sleep(10)
  13.  
  14. async def test_3(a):
  15. print("1")
  16. await asyncio.sleep(11)
  17. print("2")
  18. a.cancel()
  19.  
  20. async def main():
  21. # e = asyncio.ensure_future(test_1(asyncio.sleep(10), asyncio.sleep(10), asyncio.sleep(10)))
  22. f = asyncio.ensure_future(test_2())
  23. # g = asyncio.ensure_future(test_3(e))
  24. d = asyncio.ensure_future(test_3(f))
  25. # await asyncio.wait([e, f, g, d])
  26. await asyncio.wait([f, d])
  27.  
  28. loop = asyncio.get_event_loop()
  29. loop.run_until_complete(main())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement