worker
SAQ worker and queue.
queue
module-attribute
¶
JobConfig
dataclass
¶
Configure a Job.
Used to configure jobs enqueued via
Service.enqueue_background_task()
heartbeat
class-attribute
¶
Max time a job can survive without emitting a heartbeat. 0
to disable.
job.update()
will trigger a heartbeat.
retry_backoff
class-attribute
¶
If true, use exponential backoff for retry delays.
- The first retry will have whatever retry_delay is.
- The second retry will have retry_delay2. The third retry will have retry_delay4. And so on.
- This always includes jitter, where the final retry delay is a random number between 0 and the calculated retry delay.
- If retry_backoff is set to a number, that number is the maximum retry delay, in seconds."
retry_delay
class-attribute
¶
Seconds to delay before retrying a job.
timeout
class-attribute
¶
Max time a job can run for, in seconds.
Set to 0
for no timeout.
ttl
class-attribute
¶
Lifetime of available job information, in seconds.
0: indefinite -1: disabled (no info retained)
Queue ¶
Bases: saq.Queue
Async task queue.
Names the queue per the application slug - namespaces SAQ's redis keys to the app.
Configures msgspec
for JSON serialization/deserialization if not
otherwise configured.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args |
Any
|
Passed through to |
()
|
**kwargs |
Any
|
Passed through to |
{}
|
Worker ¶
Bases: saq.Worker
Modify behavior of saq worker for orchestration by Starlite.
create_worker_instance ¶
Parameters:
Name | Type | Description | Default |
---|---|---|---|
functions |
Collection[Callable[..., Any] | tuple[str, Callable]]
|
Functions to be called via the async workers. |
required |
before_process |
Callable[[dict[str, Any]], Awaitable[Any]] | None
|
Async function called before a job processes. |
None
|
after_process |
Callable[[dict[str, Any]], Awaitable[Any]] | None
|
Async function called after a job processes. |
None
|
Returns:
Type | Description |
---|---|
Worker
|
The worker instance, instantiated with |