Browse Source

task: fix error awaiting already scheduled task

To reproduce this issue, try `await taskMgr.add(Task.pause(1.0))`
rdb 7 years ago
parent
commit
e64a342a9f
1 changed files with 3 additions and 1 deletions
  1. 3 1
      panda/src/event/pythonTask.cxx

+ 3 - 1
panda/src/event/pythonTask.cxx

@@ -598,7 +598,9 @@ do_python_task() {
             // directly instead of having to do:
             // directly instead of having to do:
             //   await taskMgr.add(Task.pause(1.0))
             //   await taskMgr.add(Task.pause(1.0))
             AsyncTask *task = (AsyncTask *)fut;
             AsyncTask *task = (AsyncTask *)fut;
-            _manager->add(task);
+            if (!task->is_alive()) {
+              _manager->add(task);
+            }
           }
           }
           if (fut->add_waiting_task(this)) {
           if (fut->add_waiting_task(this)) {
             if (task_cat.is_debug()) {
             if (task_cat.is_debug()) {