Explorar o código

fix exception when mini-task explicitly removes itself

David Rose %!s(int64=17) %!d(string=hai) anos
pai
achega
9e5e3edc5b
Modificáronse 1 ficheiros con 8 adicións e 2 borrados
  1. 8 2
      direct/src/task/MiniTask.py

+ 8 - 2
direct/src/task/MiniTask.py

@@ -26,7 +26,10 @@ class MiniTaskManager:
         self.taskList.append(task)
         self.taskList.append(task)
 
 
     def remove(self, task):
     def remove(self, task):
-        self.taskList.remove(task)
+        try:
+            self.taskList.remove(task)
+        except ValueError:
+            pass
 
 
     def __executeTask(self, task):
     def __executeTask(self, task):
         return task(task)
         return task(task)
@@ -44,7 +47,10 @@ class MiniTaskManager:
 
 
             else:
             else:
                 # Remove the task
                 # Remove the task
-                self.taskList.remove(task)
+                try:
+                    self.taskList.remove(task)
+                except ValueError:
+                    pass
                 # Do not increment the iterator
                 # Do not increment the iterator
                 continue
                 continue