fork(1) download
  1. import asyncio
  2.  
  3.  
  4. async def cb(*args, **kwargs):
  5. print('CB CALLED')
  6. await asyncio.sleep(1)
  7. print('CB END')
  8.  
  9.  
  10. async def f():
  11. print('F CALLED')
  12. await asyncio.sleep(2)
  13. print('F END')
  14.  
  15.  
  16. async def test():
  17. fut = asyncio.ensure_future(f())
  18. fut.add_done_callback(lambda *args: asyncio.create_task(cb()))
  19. await fut
  20. await asyncio.sleep(2)
  21.  
  22.  
  23. asyncio.run(test())
Success #stdin #stdout 0.11s 15952KB
stdin
Standard input is empty
stdout
F CALLED
F END
CB CALLED
CB END