Browse Source

fix exception when mini-task explicitly removes itself

David Rose 17 years ago
parent
commit
9e5e3edc5b
1 changed files with 8 additions and 2 deletions
  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)
 
     def remove(self, task):
-        self.taskList.remove(task)
+        try:
+            self.taskList.remove(task)
+        except ValueError:
+            pass
 
     def __executeTask(self, task):
         return task(task)
@@ -44,7 +47,10 @@ class MiniTaskManager:
 
             else:
                 # Remove the task
-                self.taskList.remove(task)
+                try:
+                    self.taskList.remove(task)
+                except ValueError:
+                    pass
                 # Do not increment the iterator
                 continue