"""This module implements a minimum task manager.  It is similar in
principle to the full-featured task manager implemented in Task.py,
but it has a sharply reduced feature set--completely bare-bones, in
fact--and it is designed to be a pure-python implementation that does
not require any C++ Panda support, so that it can be loaded before
Panda has been fully downloaded. """

__all__ = ['MiniTask', 'MiniTaskManager']

class MiniTask:
    done = 0
    cont = 1

    def __init__(self, callback):
        self.__call__ = callback

class MiniTaskManager:

    def __init__(self):
        self.taskList = []
        self.running = 0

    def add(self, task, name):
        assert isinstance(task, MiniTask)
        task.name = name
        self.taskList.append(task)

    def remove(self, task):
        self.taskList.remove(task)

    def __executeTask(self, task):
        return task(task)

    def step(self):
        i = 0
        while (i < len(self.taskList)):
            task = self.taskList[i]
            ret = task(task)

            # See if the task is done
            if (ret == task.cont):
                # Leave it for next frame, its not done yet
                pass

            else:
                # Remove the task
                self.taskList.remove(task)
                # Do not increment the iterator
                continue

            # Move to the next element
            i += 1

    def run(self):
        self.running = 1
        while self.running:
            self.step()

    def stop(self):
        # Set a flag so we will stop before beginning next frame
        self.running = 0


@@ -781,32 +781,49 @@
 ve(self, task):%0A
+        try:%0A    
         self.tas
@@ -836,24 +836,68 @@
 remove(task)
+%0A        except ValueError:%0A            pass
 %0A%0A    def __
@@ -1295,16 +1295,41 @@
 he task%0A
+                try:%0A    
         
@@ -1355,32 +1355,92 @@
 st.remove(task)%0A
+                except ValueError:%0A                    pass%0A
                 

fix exception when mini-task explicitly removes itself