thread-task

organize and run thread tasks


Licenses
GPL-3.0/GPL-3.0+
Install
pip install thread-task==0.9.7

Documentation

thread_task is built on top of threading and allows to organize tasks and run them parallel.

You can:

  • build chains of tasks, which execute tasks sequentially in a single thread
  • build parent-child relationships, which allows to construct trees of tasks
  • stop tasks, which also stops the execution of child tasks
  • continue tasks, which also continues the execution of child tasks
  • restart finished or stopped tasks
  • join tasks, which means waiting until the task and its children are finished

A thread_task is not like a function, it doesn't return results. Think of it as an instruction to a reliable but independently acting person. If feedback is needed, this can be done by callback functions. Communication between tasks is possible by mutable objects, which can be red or changed by multiple tasks.

The following task types exist:

  • Task: Executes a single callable or a chain of callables.
  • Repeated: Executes a callable multiple times.
  • Periodic: Executes a callable periodically
  • Sleep: Sleeps for a given time, is similar to time.sleep, but can be stopped and continued

Read thread-task.readthedocs.io for more details.