Skip to content

Instantly share code, notes, and snippets.

@ysc3839

ysc3839/test.py Secret

Created September 8, 2021 02:26
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 ysc3839/4445c6c2bc1e0ce02790a52fed0c8b38 to your computer and use it in GitHub Desktop.
Save ysc3839/4445c6c2bc1e0ce02790a52fed0c8b38 to your computer and use it in GitHub Desktop.
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