tasktronaut.backends package

Submodules

tasktronaut.backends.rq module

RQ Backend implementation for Tasktronaut process execution.

This module provides a concrete implementation of the Backend abstract base class using the RQ (Redis Queue) job queue library. It enables asynchronous execution of Tasktronaut processes with support for job dependencies and Redis-backed job persistence.

class tasktronaut.backends.rq.RqBackend(queue)

Bases: Backend

Backend implementation using RQ (Redis Queue) for process execution.

This backend enqueues process start, task, and completion callbacks to an RQ queue for asynchronous execution. It leverages RQ’s job dependency features to ensure proper task ordering and provides Redis-backed persistence of job state.

Parameters:

queue (rq.Queue) – The RQ Queue instance to which jobs will be enqueued

enqueue_perform_complete(identifier, module_name, definition_class, depends_on=None)

Enqueue a process completion callback to the RQ queue.

Schedules the execution of the process completion callback by enqueueing the perform_complete method to the configured RQ queue. The job will optionally depend on one or more other jobs before execution.

Parameters:
  • identifier (str) – Unique identifier for the process execution instance

  • module_name (str) – Fully qualified module name containing the process definition

  • definition_class (str) – Name of the process definition class to instantiate

  • depends_on (Optional[Union[Job, List[Job]]]) – Optional job or list of jobs that this job depends on. If provided, this job will not execute until all dependencies complete.

Returns:

RQ Job object representing the enqueued task

Return type:

Job

enqueue_perform_start(identifier, module_name, definition_class, depends_on=None)

Enqueue a process start callback.

Schedules the execution of the process start callback, which allows the process definition to perform initialization logic when execution begins.

Parameters:
  • identifier (str) – Unique identifier for the process execution instance

  • module_name (str) – Fully qualified module name containing the process definition

  • definition_class (str) – Name of the process definition class to instantiate

  • depends_on (Optional[Job]) – Optional job that this job depends on. If provided, this job will not execute until the dependency completes.

Returns:

Job object representing the enqueued task

Return type:

Job

enqueue_perform_task(identifier, module_name, definition_class, function_name, description, kwargs, depends_on=None)

Enqueue a process task for execution to the RQ queue.

Schedules the execution of a specific task function within a process definition by enqueueing the rq_perform_task method to the configured RQ queue. Uses a wrapper method to handle RQ-specific parameter handling.

Parameters:
  • identifier (str) – Unique identifier for the process execution instance

  • module_name (str) – Fully qualified module name containing the process definition

  • definition_class (str) – Name of the process definition class to instantiate

  • function_name (str) – Name of the task method to execute

  • description (Optional[str]) – Human-readable description of the task

  • kwargs (Dict[str, Any]) – Keyword arguments to pass to the task function

  • depends_on (Optional[Job]) – Optional job that this job depends on. If provided, this job will not execute until the dependency completes.

Returns:

RQ Job object representing the enqueued task

Return type:

Job

classmethod rq_perform_task(identifier, module_name, definition_class, function_name, task_description, task_kwargs)

Execute a process task from within an RQ job context.

This classmethod serves as the RQ job entry point for task execution. It retrieves the current RQ job, and delegates to the perform_task method.

Parameters:
  • identifier (str) – Unique identifier for the process execution instance

  • module_name (str) – Fully qualified module name containing the process definition

  • definition_class (str) – Name of the process definition class to instantiate

  • function_name (str) – Name of the task method to execute

  • task_description (Description) – Human-readable description of the task

  • task_kwargs (Dict[str, Any]) – Keyword arguments to pass to the task function

Module contents