Skip to content

Instantly share code, notes, and snippets.

@loretoparisi
Created April 18, 2019 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loretoparisi/ef2c2a8d9347fcec5706408aa3b88796 to your computer and use it in GitHub Desktop.
Save loretoparisi/ef2c2a8d9347fcec5706408aa3b88796 to your computer and use it in GitHub Desktop.
Python Async Await with AsyncIO
import asyncio
async def demo():
print("foo")
await asyncio.sleep(5)
return "bar"
def main():
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
result = loop.run_until_complete(demo())
print(result)
@loretoparisi
Copy link
Author

>>> main()
foo
bar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment