I’m trying to cancel a task that is awaiting on the completion of another future, however this cause the code to abort.
Looking a bit into the code, it seems that
AsyncTaskChain::do_remove() (which is called by
cancel()) does not remove a task in
cancel()method checks if the task is done after calling remove, and, if not, an assert is triggered.
from panda3d.core import AsyncFuture future = AsyncFuture() async def waiting_task(): await future async def cancel_task(t): print(t.get_state()) t.cancel() import direct.directbase.DirectStart t = taskMgr.add(waiting_task()) taskMgr.add(cancel_task(t)) base.run()
And the output is :
6 Assertion failed: done() at line 465 of panda/src/event/asyncTask.cxx :task(error): PythonTask cancel_task exception was never retrieved: Traceback (most recent call last): File "test/test_async3.py", line 10, in cancel_task t.cancel() AssertionError: done() at line 465 of panda/src/event/asyncTask.cxx