Skip to content

Instantly share code, notes, and snippets.

@huytung228
Last active July 8, 2021 03:37
Show Gist options
  • Save huytung228/bf97d30f26502e6c0f7359627d3e2cc5 to your computer and use it in GitHub Desktop.
Save huytung228/bf97d30f26502e6c0f7359627d3e2cc5 to your computer and use it in GitHub Desktop.
import asyncio
async def count():
print("One")
await asyncio.sleep(1)
print("Two")
async def main():
await asyncio.gather(count(), count(), count())
if __name__ == "__main__":
import time
s = time.perf_counter()
asyncio.run(main())
elapsed = time.perf_counter() - s
print(f"{__file__} executed in {elapsed:0.2f} seconds.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment