Last active
October 29, 2018 03:08
-
-
Save barrachri/80b20f239567b2032606835bdaae849d to your computer and use it in GitHub Desktop.
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
"""Needs Python 3.7""" | |
import asyncio | |
import time | |
def blocking(): | |
print("\tStarting sleeping") | |
time.sleep(5) | |
print("\tSleeping completed") | |
return "Hello World" | |
async def hello_world(): | |
print("Waiting for blocking") | |
loop = asyncio.get_running_loop() | |
future = loop.run_in_executor(None, blocking) | |
print("I don't want to wait") | |
result = await future | |
print(result) | |
asyncio.run(hello_world()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment