Advertisement
Guest User

Untitled

a guest
Feb 21st, 2020
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. import threading
  2. import asyncio
  3. import time
  4. def run_async_background(coro):
  5. def func():
  6. loop = asyncio.new_event_loop()
  7. loop.run_until_complete(coro)
  8. loop.close()
  9. Thread(target=func).start()
  10. async def prin(text):
  11. print(str(text))
  12. run_async_backgroundcoro(prin(time.ctime()))
  13. run_async_backgroundcoro(prin(time.ctime()))
  14. run_async_backgroundcoro(prin(time.ctime()))
  15. run_async_backgroundcoro(prin(time.ctime()))
  16. run_async_backgroundcoro(prin(time.ctime()))
  17. run_async_backgroundcoro(prin(time.ctime()))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement