WorkerSettings

class safir.arq.WorkerSettings(functions, redis_settings, job_completion_wait, job_timeout, max_jobs, allow_abort_jobs=False, queue_name='arq:queue', on_startup=None, on_shutdown=None, cron_jobs=None)

Bases: object

Configuration class for an arq worker.

The arq command-line tool reads a class of the name WorkerSettings in the module it was given on the command line and turns its attributes into parameters to arq.worker.Worker. This dataclass represents the subset of the available settings that Safir applications have needed to date, as an aid for constructing that configuration object.

Parameters:

Attributes Summary

allow_abort_jobs

Whether to allow jobs to be aborted.

cron_jobs

Cron jobs to run.

functions

Coroutines to register as arq worker entry points.

job_completion_wait

How long to wait for jobs to complete before cancelling them.

job_timeout

Maximum timeout for all jobs.

max_jobs

Maximum number of jobs that can be run at one time.

on_shutdown

Coroutine to run on shutdown.

on_startup

Coroutine to run on startup.

queue_name

Name of arq queue to listen to for jobs.

redis_settings

Redis configuration for arq.

Attributes Documentation

allow_abort_jobs: bool = False

Whether to allow jobs to be aborted.

cron_jobs: Sequence[CronJob] | None = None

Cron jobs to run.

functions: Sequence[Function | WorkerCoroutine] = <dataclasses._MISSING_TYPE object>

Coroutines to register as arq worker entry points.

job_completion_wait: Union[int, float, timedelta] = <dataclasses._MISSING_TYPE object>

How long to wait for jobs to complete before cancelling them.

job_timeout: Union[int, float, timedelta] = <dataclasses._MISSING_TYPE object>

Maximum timeout for all jobs.

max_jobs: int = <dataclasses._MISSING_TYPE object>

Maximum number of jobs that can be run at one time.

on_shutdown: StartupShutdown | None = None

Coroutine to run on shutdown.

on_startup: StartupShutdown | None = None

Coroutine to run on startup.

queue_name: str = 'arq:queue'

Name of arq queue to listen to for jobs.

redis_settings: RedisSettings = <dataclasses._MISSING_TYPE object>

Redis configuration for arq.