Skip to content

Instantly share code, notes, and snippets.

@narenaryan
Created January 6, 2022 17:01
Show Gist options
  • Select an option

  • Save narenaryan/81d5a0b99e65bfb5ce1e2e06e1eee9d3 to your computer and use it in GitHub Desktop.

Select an option

Save narenaryan/81d5a0b99e65bfb5ce1e2e06e1eee9d3 to your computer and use it in GitHub Desktop.
import asyncio
# A co-routine
async def add(x: int, y: int):
return x + y
# An event loop
loop = asyncio.get_event_loop()
# Pass the co-routine to the loop
result = loop.run_until_complete(add(3, 4))
print(result) # Prints 7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment