build_worker¶
- safir.arq.uws.build_worker(worker, config, logger)¶
Construct an arq worker for the provided backend function.
Builds an arq worker configuration that wraps the provided sync function and executes it on messages to the default arq queue. Messages to the UWS queue will be sent on job start and after job completion so that the UWS database can be updated.
Unfortunately, the built-in arq
on_job_start
andafter_job_end
hooks can’t be used because they don’t receive any arguments to the job and we need to tell the UWS handlers the job ID to act on. This means that we’ll send the UWS queue message before the results are recorded in Redis, so the UWS handler has to deal with that.- Parameters:
worker (
Callable
[[TypeVar
(T
, bound= BaseModel),WorkerJobInfo
,BoundLogger
],list
[WorkerResult
]]) – Synchronous function that does the actual work. This function will be run in a thread pool of size one.config (
WorkerConfig
[TypeVar
(T
, bound= BaseModel)]) – UWS worker configuration.logger (
BoundLogger
) – Logger to use for messages.
- Return type: