-
-
Save ysc3839/4445c6c2bc1e0ce02790a52fed0c8b38 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
from asyncio import Future | |
callback_list = [] | |
def func(callback): | |
callback_list.append(callback) | |
def func_await(): | |
future = Future() | |
def on_finish(): | |
future.set_result(None) | |
func(on_finish) | |
return future | |
async def test(): | |
print(1) | |
await func_await() | |
print(2) | |
test() | |
test() | |
while len(callback_list) != 0: | |
callback = callback_list.pop(0) | |
callback() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment