orangeqs.juice.task._task#

Base class for tasks.

Module Contents#

Classes#

Task

Base class for tasks that can be executed by a service.

TaskFuture

Future that resolves to the result of a task.

API#

class orangeqs.juice.task._task.Task(/, **data: Any)#

Bases: pydantic.BaseModel

Base class for tasks that can be executed by a service.

classmethod type() str#

Return the unique name of the task type.

This is used to validate the model on the service side and route the task to the correct handler. Defaults to the class name.

Warning: The name of the type should be unique per service. Can be overridden to prevent name clashes.

property hidden_fields: set[str]#

Return a set of field names to exclude from the display name.

By default, this excludes the parallel class variable.

property display_name: str#

Return a human-readable name for the task.

Defaults to the task type and all fields except those in hidden_fields. For example: MyTask: param1=42, param2='foo'.

Can be overridden to provide a more descriptive name.

parallel: ClassVar[bool]#

False

Whether this task can be executed in parallel with other tasks.

Tasks are executed sequentially by default. Classes that set this to True will be executed as soon as they are received, without waiting for other tasks to finish.

class orangeqs.juice.task._task.TaskFuture(task_id: str)#

Bases: asyncio.Future[orangeqs.juice.task._task._T]

Future that resolves to the result of a task.

task_id: str#

None

Unique identifier of the task.