Pausing Tasks

first of all: I found an inconsistency withhin the documentation of Tasks. In the API there are a few more return values than mentioned in the manual.
API: … !task.Task

Are Pause or Pickup obsolete?

Another thing:
There are task chains, kind of grouping for tasks within a manager. Is the only aim of that grouping threading? The API tells that there are only 2 methods concerning task chains. One is for setting one up and another for checking if a certain chain has been defined.

I thought I could use those chains as groups for defining what tasks to stop at a certain time, but I guess I’ll have to do with multiple TaskManagers or multiple DirectObjects (which keep trac of their tasks they put into the main task anager).

Now, given I manage to stop all tasks of a particular group and start again later, I’d have to keep track of task.time. Anything else I should keep an eye on?

Any other ideas on how to implement “pause”?

From asyncTask.h:

  enum DoneStatus {
    DS_done,      // normal task completion
    DS_cont,      // run task again next epoch
    DS_again,     // start the task over from the beginning
    DS_pickup,    // run task again this frame, if frame budget allows
    DS_exit,      // stop the enclosing sequence
    DS_pause,     // pause, then exit (useful within a sequence)
    DS_interrupt, // interrupt the task manager, but run task again

This, pause and pickup are not obsolete, but they are obscure and infrequently used. “pickup” is only useful when the task chain has a frame budget in effect, which is an advanced feature of task chains that can be used to constrain the amount of time per frame spent in all tasks in the chain. “pause” is only useful when building a task sequence, which is not to be confused with a Sequence interval. A task sequence is created by the constructor Task.sequence(), but this is a fairly obscure feature and not particularly recommended.

Task chains can be used for more than just threading, but threading is their main purpose. Normally you would use task chains only to create a group of tasks that have specialized timing requirements, for instance tasks that are run less frequently than the main task chains or whatever.

You could use task chains for grouping tasks that you want to pause as a unit, but that would be kind of silly. Just store these tasks in your own Python list instead.

(And whether you decide to use task chains for this purpose or not, you certainly shouldn’t create more than one TaskManager. That’s just asking for trouble.)

I believe ynjh_jo once implemented a feature to pause and restart all of the tasks in the task manager. It’s pretty straightforward.


I do use 0-frameBudget task chain to halt ordinary tasks (not doLater ones), without having to .add() them again to taskMgr on resume, so I don’t have to deal with the arguments to pass.

On resume, I just need to set them to the default chain.

Hmm, I believe if you store the Task object, you can add() or remove() it with impunity–it carries its set of arguments with it.

But, OK, an imaginative use for task chains. :slight_smile:


That’s true, and now I remember my main reason to use taskChain is to avoid the uponDeath function from being ran upon removal, which is not wanted.

Ok, first idea was to have a DO for grouping tasks.
It didn’t work out well, because I use DOs for managing other things already.

Then i wanted to tag the tasks by putting keywords into their names and pause by taskMgr.getTaskMatching() but that didn’t work at all. Always returned an empty list.

What worked out in the end was using task chains and setting the frameBudget to 0 and -1 explicitly on particular task chains.

Thank goes to Craig, ynjh_jo and drwr :slight_smile: