ArqQueue

class safir.arq.ArqQueue(*, default_queue_name: str = 'arq:queue')

Bases: object

An 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.

Attributes Summary

default_queue_name

Name of the default queue, if the _queue_name parameter is no set in method calls.

Methods Summary

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])

The job result, if available.

Attributes Documentation

default_queue_name

Name of the default queue, if the _queue_name parameter is no set in method calls.

Methods Documentation

abstract async enqueue(task_name: str, *task_args: Any, _queue_name: Optional[str] = None, **task_kwargs: Any) JobMetadata

Add a job to the queue.

Parameters:
  • task_name (str) – The function name to run.

  • *args – Positional arguments for the task function.

  • _queue_name (str) – Name of the queue.

  • **kwargs – Keyword arguments passed to the task function.

Returns:

Metadata about the queued job.

Return type:

JobMetadata

Raises:

JobNotQueued – Raised if the job is not successfully added to the queue.

abstract async get_job_metadata(job_id: str, queue_name: Optional[str] = None) JobMetadata

Get metadata about a Job.

Parameters:
  • job_id (str) – The job’s identifier. This is the same as the JobMetadata.id attribute, provided when initially adding a job to the queue.

  • queue_name (str, optional) – Name of the queue.

Returns:

Metadata about the queued job.

Return type:

JobMetadata

Raises:

JobNotFound – Raised if the job is not found in the queue.

abstract async get_job_result(job_id: str, queue_name: Optional[str] = None) JobResult

The job result, if available.

Parameters:
  • job_id (str) – The job’s identifier. This is the same as the JobMetadata.id attribute, provided when initially adding a job to the queue.

  • queue_name (str, optional) – Name of the queue.

Returns:

The job’s result, along with metadata about the queued job.

Return type:

JobResult

Raises: