Skip to content

Instantly share code, notes, and snippets.

@Battleroid
Created November 30, 2018 14:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Battleroid/60e91ae01a3329e42ee679dcc1cdca2f to your computer and use it in GitHub Desktop.
Save Battleroid/60e91ae01a3329e42ee679dcc1cdca2f to your computer and use it in GitHub Desktop.
import asyncio
import time
async def hello():
t = time.time()
print(f'Hello {t}')
return t
while True:
time.sleep(5)
print(f'New loop {time.time()}')
tasks = [hello() for _ in range(10)]
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
times = loop.run_until_complete(asyncio.gather(*tasks))
loop.close()
print(times)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment