ArqQueue¶
- class safir.arq.ArqQueue(*, default_queue_name='arq:queue')¶
Bases:
object
A common interface for working with an arq queue that can be implemented either with a real Redis backend, or an in-memory repository for testing.
See also
RedisArqQueue
Production implementation with a Redis store.
MockArqQueue
In-memory implementation for testing and development.
- Parameters:
default_queue_name (
str
, default:'arq:queue'
)
Attributes Summary
Name of the default queue, if the
_queue_name
parameter is not set in method calls.Methods Summary
abort_job
(job_id[, queue_name, timeout])Abort a queued or running job.
enqueue
(task_name, *task_args[, _queue_name])Add a job to the queue.
get_job_metadata
(job_id[, queue_name])Get metadata about a
Job
.get_job_result
(job_id[, queue_name])Retrieve the job result, if available.
Attributes Documentation
- default_queue_name¶
Name of the default queue, if the
_queue_name
parameter is not set in method calls.
Methods Documentation
- abstract async abort_job(job_id, queue_name=None, *, timeout=None)¶
Abort a queued or running job.
The worker must be configured to allow aborting jobs for this to succeed.
- abstract async enqueue(task_name, *task_args, _queue_name=None, **task_kwargs)¶
Add a job to the queue.
- Parameters:
- Returns:
Metadata about the queued job.
- Return type:
- Raises:
JobNotQueued – Raised if the job is not successfully added to the queue.
- abstract async get_job_metadata(job_id, queue_name=None)¶
Get metadata about a
Job
.- Parameters:
job_id (
str
) – The job’s identifier. This is the same as theJobMetadata.id
attribute, provided when initially adding a job to the queue.
- Returns:
Metadata about the queued job.
- Return type:
- Raises:
JobNotFound – Raised if the job is not found in the queue.
- abstract async get_job_result(job_id, queue_name=None)¶
Retrieve the job result, if available.
- Parameters:
job_id (
str
) – The job’s identifier. This is the same as theJobMetadata.id
attribute, provided when initially adding a job to the queue.
- Returns:
The job’s result, along with metadata about the queued job.
- Return type:
- Raises:
JobNotFound – Raised if the job is not found in the queue.
JobResultUnavailable – Raised if the job’s result is unavailable for any reason.