fork download
  1. import asyncio
  2.  
  3. fut = asyncio.Future()
  4.  
  5. async def waiter():
  6. await fut
  7.  
  8. fut_waiter = asyncio.ensure_future(waiter())
  9.  
  10. # cancel the waiter on fut
  11. fut_waiter.cancel()
  12.  
  13. print(fut.done())
  14.  
Success #stdin #stdout #stderr 0.1s 17140KB
stdin
Standard input is empty
stdout
False
stderr
Task was destroyed but it is pending!
task: <Task cancelling coro=<waiter() running at ./prog.py:5>>
sys:1: RuntimeWarning: coroutine 'waiter' was never awaited