Created
June 18, 2019 11:24
-
-
Save chaudum/d2bdb2ae27847dfdf5f19bab1ca109c8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 do_something_long_running(sec=1) -> bool: | |
print(f"sleep for {sec}s") | |
await asyncio.sleep(sec) | |
return True | |
async def coro_a(t): | |
return await do_something_long_running(t) | |
async def coro_b(t): | |
return await not_a_coro(t) | |
async def coro_c(t): | |
return not_a_coro(t) | |
def not_a_coro(t): | |
return do_something_long_running(t) | |
async def main(): | |
print(await coro_a(1)) | |
print(await coro_b(2)) | |
print(await coro_c(3)) | |
if __name__ == "__main__": | |
asyncio.run(main()) |
Author
chaudum
commented
Jun 18, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment