Created
November 30, 2018 14:55
-
-
Save Battleroid/60e91ae01a3329e42ee679dcc1cdca2f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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