Advertisement
DigitalMag

simplest friendship asyncio with sync

Nov 11th, 2020
794
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.38 KB | None | 0 0
  1. import time
  2. import asyncio
  3.  
  4. loop = asyncio.get_event_loop()
  5.  
  6. async def a_print(v):
  7.     time.sleep(v)
  8.     print(v)
  9.     return v**2
  10.  
  11. async def main(sync, v):
  12.     # loop.create_task(a_print(v+1))
  13.     loop.create_task(a_print(v+1))
  14.     start()
  15.     time.sleep(v)
  16.     print(v)
  17.  
  18. def start():
  19.     print(9)
  20.  
  21. if __name__ == '__main__':
  22.     loop.run_until_complete(main(start, 1))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement