浏览代码

task: Fix memory leak when removing a task awaiting non-Panda future

rdb 5 年之前
父节点
当前提交
b5d0e9eafc
共有 1 个文件被更改,包括 6 次插入0 次删除
  1. 6 0
      panda/src/event/pythonTask.cxx

+ 6 - 0
panda/src/event/pythonTask.cxx

@@ -779,6 +779,12 @@ void PythonTask::
 upon_death(AsyncTaskManager *manager, bool clean_exit) {
   AsyncTask::upon_death(manager, clean_exit);
 
+  // If we were polling something when we were removed, get rid of it.
+  if (_future_done != nullptr) {
+    Py_DECREF(_future_done);
+    _future_done = nullptr;
+  }
+
   if (_upon_death != Py_None) {
 #if defined(HAVE_THREADS) && !defined(SIMPLE_THREADS)
     // Use PyGILState to protect this asynchronous call.