import asyncio fut = asyncio.Future() async def waiter(): await fut fut_waiter = asyncio.ensure_future(waiter()) # cancel the waiter on fut fut_waiter.cancel() print(fut.done())
Standard input is empty
False
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