Skip to content

worker

SAQ worker and queue.

queue module-attribute

queue = Queue(redis.client)

Queue instance instantiated with redis instance.

Queue

Queue(*args, **kwargs)

Bases: saq.Queue

Async task queue.

Configures orjson for JSON serialization/deserialization if not otherwise configured.

Parameters:

Name Type Description Default
*args Any

Passed through to saq.Queue.__init__()

()
**kwargs Any

Passed through to saq.Queue.__init__()

{}

Worker

Bases: saq.Worker

Modify behavior of saq worker for orchestration by Starlite.

on_app_startup async

on_app_startup()

Attach the worker to the running event loop.

create_worker_instance

create_worker_instance(functions, before_process=None, after_process=None)

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