'Add \'task\' to the task list.
\'task\' may be a function, generator or scheduler.
The task is deemed to be finished when either it returns a
false value or raises StopIteration.'

def add_task(self, task, atfront=0):

    try:
        self.tasks.remove(task)
    except ValueError:
        pass
    if atfront:
        self.tasks.insert(0, task)
    else:
        self.tasks.append(task)
    for callback in self.callbacks:
        callback(self)
