pipeline_lock
pipeline_lock
¶
Single-pipeline-at-a-time lock for protecting local LLM resources.
PipelineInfo(pipeline_id, pipeline_type, period)
dataclass
¶
Metadata about the currently running pipeline.
PipelineLock()
¶
Ensures only one pipeline runs at a time across the backend.
Usage::
lock = PipelineLock()
if not await lock.acquire("tisk", 10):
raise RuntimeError("Another pipeline is running")
try:
... # run pipeline
finally:
lock.release()
Source code in pspcz_analyzer/services/pipeline_lock.py
is_locked
property
¶
Whether a pipeline is currently running.
current
property
¶
Info about the currently running pipeline, or None.
acquire(pipeline_type, period)
async
¶
Try to acquire the lock for a pipeline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pipeline_type
|
str
|
Type of pipeline (e.g. "tisk", "amendment"). |
required |
period
|
int
|
Electoral period number. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if lock acquired, False if another pipeline is running. |
Source code in pspcz_analyzer/services/pipeline_lock.py
release()
¶
Release the pipeline lock.