Created
April 18, 2019 15:44
-
-
Save loretoparisi/ef2c2a8d9347fcec5706408aa3b88796 to your computer and use it in GitHub Desktop.
Python Async Await with AsyncIO
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Author
loretoparisi
commented
Apr 18, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment