Skip to content

Instantly share code, notes, and snippets.

@moacirmoda
Last active June 21, 2017 02:09
Show Gist options
  • Save moacirmoda/a8ebcc41b119242e5528a60ca2c2a9a7 to your computer and use it in GitHub Desktop.
Save moacirmoda/a8ebcc41b119242e5528a60ca2c2a9a7 to your computer and use it in GitHub Desktop.
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