Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import asyncio
- task = None
- def do_stuff(on_finished):
- result = 5 + 5
- asyncio.create_task(on_finished(result))
- def on_finished(result):
- print("on_finished called")
- async def actual_work():
- await asyncio.sleep(0.1)
- print(result)
- return actual_work()
- async def main():
- do_stuff(on_finished)
- print("do_stuff exited")
- await asyncio.sleep(0.2)
- if __name__ == "__main__":
- asyncio.run(main())
Advertisement
Add Comment
Please, Sign In to add comment