Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. import asyncio
  2. import datetime
  3.  
  4. async def foo():
  5. now = datetime.now()
  6. ten_mins_from_now=now + datetime.timedelta(minutes=10)
  7. while datetime.now()< ten_mins_from_now: # must be changed into a coroutine?
  8. sleep(30)
  9. return 'foo has returned'
  10.  
  11. async def print_job():
  12. print('can i print before foo() returns?')
  13.  
  14. async def main():
  15. await foo():
  16. await print_job()
  17.  
  18. asyncio.run(main())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement