checkmate
Extension of the basic CheckMateEngine that adds RDBMS persistence via bind/unbind hooks.
Attributes
Classes
CheckMate
CheckMate(
checkmate_factory: Callable[..., CheckMate],
stage_templates: List[STAGE] | None = None,
task_id: str | None = None,
description: str | None = None,
no_lock: bool = False,
retry_policy: RetryPolicy | None = None,
max_attempts: int | None = None,
bind_lock_timeout: int | None = None,
auto_cleanup: bool | None = None,
force_create: bool = False,
queue: str = DEFAULT_QUEUE_NAME,
tags: List[str] | None = None,
)
Bases: CheckMateEngine[STAGE, STAGE_RESULT]
ManagedTask extends TaskEngine to add RDBMS persistence via bind/unbind hooks.
This class provides additional functionality to bind and unbind tasks with a relational database management system (RDBMS). It ensures that task states are persisted in the database during the bind and unbind operations.
Attributes:
-
description
–An optional description of the task.
Initializes a ManagedTask instance.
This constructor sets up a ManagedTask with optional stage templates, task ID, description, and various configuration options. It ensures that the task is properly configured for RDBMS persistence and task engine operations.
Parameters:
-
stage_templates
(List[STAGE] | None
, default:None
) –Optional list of stage templates.
-
task_id
(str | None
, default:None
) –Optional unique identifier for the task.
-
description
(str | None
, default:None
) –Optional description of the task.
-
no_lock
(bool
, default:False
) –Boolean flag to indicate if locking should be disabled.
-
retry_policy
(RetryPolicy | None
, default:None
) –Optional retry policy for the task.
-
max_attempts
(int | None
, default:None
) –Optional maximum number of attempts for the task.
-
bind_lock_timeout
(int | None
, default:None
) –Optional timeout for bind lock.
-
auto_cleanup
(bool | None
, default:None
) –Optional flag to enable automatic cleanup.
-
force_create
(bool
, default:False
) –Boolean flag to indicate if the task should be created if it doesn’t exist.
-
queue
(str
, default:DEFAULT_QUEUE_NAME
) –Queue name for the task.
Example
with ManagedTask(
stage_templates=[
NOPStage(
stage_name="stage1",
description="No-op stage for testing",
state=BaseStageState(),
),
NOPStage(
stage_name="stage2",
description="No-op stage for testing",
state=BaseStageState(),
),
],
description="Sample task",
no_lock=True,
retry_policy=RetryPolicy.RETRY,
max_attempts=3,
bind_lock_timeout=5,
auto_cleanup=False
) as task:
# Perform task operations here...
Attributes
Functions
bind
Bind the task to the current process.
This method ensures that the task is persisted in the RDBMS. If the task does not exist in the database, it will be created.
unbind
Unbind the task from the current process.
This method ensures that the task state is updated in the RDBMS. If the task does not exist in the database, a warning is logged.
Parameters:
-
clean
(bool
, default:False
) –Boolean flag to indicate if the task should be marked as cleaned.