Last active
June 21, 2017 02:09
-
-
Save moacirmoda/a8ebcc41b119242e5528a60ca2c2a9a7 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 | |
from datetime import datetime | |
async def get_number(number): | |
await asyncio.sleep(1) | |
print("%s - %s" % (datetime.now(), number)) | |
loop = asyncio.get_event_loop() | |
tasks = [] | |
for number in range(10): | |
tasks.append(get_number(number)) | |
loop.run_until_complete(asyncio.wait(tasks)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment