Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. async def task1():
  2. await asyncio.sleep(3)
  3. print("after sleep")
  4.  
  5. async def task2():
  6. t = loop.create_task(task1())
  7. await asyncio.sleep(1)
  8. t.cancel()
  9. # can the following code lines assume that task1 is no longer running?
  10.  
  11. loop = asyncio.get_event_loop()
  12. loop.run_forever()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement