RedisArqQueue

class safir.arq.RedisArqQueue(pool, *, default_queue_name='arq:queue')

Bases: ArqQueue

A distributed queue, based on arq and Redis.

Parameters:
  • pool (ArqRedis)

  • default_queue_name (str, default: 'arq:queue')

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.

initialize(redis_settings, *[, ...])

Initialize a RedisArqQueue from Redis settings.

Methods Documentation

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.

Parameters:
  • job_id (str) – The job’s identifier.

  • queue_name (str | None, default: None) – Name of the queue.

  • timeout (float | None, default: None) – How long to wait for the job result before raising TimeoutError. If None, waits forever.

Return type:

bool

async enqueue(task_name, *task_args, _queue_name=None, **task_kwargs)

Add a job to the queue.

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

  • *task_args (Any) – Positional arguments for the task function.

  • _queue_name (str | None, default: None) – Name of the queue.

  • **task_kwargs (Any) – 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.

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 the JobMetadata.id attribute, provided when initially adding a job to the queue.

  • queue_name (str | None, default: None) – 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.

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 the JobMetadata.id attribute, provided when initially adding a job to the queue.

  • queue_name (str | None, default: None) – Name of the queue.

Returns:

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

Return type:

JobResult

Raises:
async classmethod initialize(redis_settings, *, default_queue_name='arq:queue')

Initialize a RedisArqQueue from Redis settings.

Parameters:
Return type:

Self