Jobs¶
Jobs can be scheduled to run as:
Fire-and-forget tasks:
saq.queue.Queue.enqueue
Wait-for-result tasks:
saq.queue.Queue.apply
Sample code:
# schedule a job normally
job = await queue.enqueue("test", a=1)
# wait 1 second for the job to complete
await job.refresh(1)
print(job.results)
# run a job and return the result
print(await queue.apply("test", a=2))
# schedule a job in 10 seconds
await queue.enqueue("test", a=1, scheduled=time.time() + 10)
Common¶
Explicit vs Implicit job calling¶
TODO: queue.enqueue(Job(…)) vs known-parameters
Job defaults¶
TODO: Discuss example to subclass Queue to configure defaults for enqueue (e.g. retries)
Retries¶
TODOL Discuss that retries ALWAYS jitter