Skip to content

Instantly share code, notes, and snippets.

@JialunC
Last active October 24, 2018 17:32
Show Gist options
  • Save JialunC/0c473d99b32d05ef6e30d4f65336fe6f to your computer and use it in GitHub Desktop.
Save JialunC/0c473d99b32d05ef6e30d4f65336fe6f to your computer and use it in GitHub Desktop.
A simple async code
import asyncio
async def print_something_twice():
print('Hello World')
await asyncio.sleep(1)
print('Hello to you three')
async def print_something():
print('Hello to you two')
loop = asyncio.get_event_loop()
tasks = [loop.create_task(print_something_twice()), loop.create_task(print_something())]
loop.run_until_complete(asyncio.wait(tasks))
loop.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment