AssertionError: _num_busy_threads == 0

ETC hit this error when porting one of their projects to 1.6.2.
The problem is when invoking the task manager inside a task:

from direct.directbase import DirectStart
taskMgr.add(taskMgr.step, "test", extraArgs=[])
run()

Further stripping it down:

from pandac.PandaModules import AsyncTaskManager, PythonTask
a = AsyncTaskManager("test")
p = PythonTask(a.poll)
p.setArgs(None, False)
a.add(p)
a.poll()

Both pieces of code yield this error:

AssertionError: _num_busy_threads == 0 at line 865 of asyncTaskChain.cxx

Is this just the new behavior and is it simply impossible to do it like this, or is there a way we can still allow it?
Otherwise I think there still needs to be some kind of protection around it - so that it will at least output a meaningful error message. This one wasn’t easy for me to track down.

Recursively running the task manager from within a task isn’t supported. It really never was intended to be supported, though it used to work in the old task manager, accidentally.

It surprised me the first time I saw ynjh_jo report this error; it had never occurred to me that anyone would want to do this. But I guess it is a quick-and-dirty way to let a frame go by, even though when you think about what is actually happening internally, it’s actually a very dirty way.

It might be possible to put in code to support this, but I don’t think that’s a great idea. There’s no good reason to run the task manager recursively, especially now that we have support for yield.

Putting in a clearer error message is probably a good idea. I’ll look into this.

David

As far as I remember, the problem was that Panda3D does some work between two frames, that is not done inside a frame. With this trick some internal ressources were cleaned up. But it is likely that I don’t remember correctly.