Guest User

Untitled

a guest
Feb 23rd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. import asyncio
  2.  
  3. async def testProc():
  4. for i in range(10):
  5. await asyncio.sleep(1)
  6. print("sleep")
  7.  
  8. def callbackProc():
  9. #print("Callback event")
  10. loop = asyncio.get_event_loop()
  11. loop.call_soon(callbackProc)
  12.  
  13. if __name__ == '__main__':
  14. loop = asyncio.get_event_loop()
  15. try:
  16. print('task creation started')
  17. asyncio.ensure_future(testProc())
  18. loop.call_soon(callbackProc)
  19. loop.run_forever()
  20. finally:
  21. loop.close()
Add Comment
Please, Sign In to add comment