ruffyen

asyncio

Aug 21st, 2014
364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.29 KB | None | 0 0
  1. import asyncio
  2. import time
  3.  
  4. @asyncio.coroutine
  5. def sleepy():
  6.     print("before sleep", time.time())
  7.     yield from asyncio.sleep(5)
  8.     print("after sleep", time.time())
  9.  
  10.  
  11. asyncio.get_event_loop().run_until_complete(sleepy())
  12.  
  13.  
  14. for x in range(10):
  15.     print(x)
  16.     time.sleep(1)
Advertisement
Add Comment
Please, Sign In to add comment