Module 20 ยท Task Queues & Events โ Lesson 2 of 4 ยท ~8 min
Workers & retries
A task is just an async function that takes ctx
arq tasks look almost exactly like the route handlers you've been writing since module 24 โ the only new thing is the first parameter, ctx: a dict arq hands every task, carrying job metadata (ctx["job_id"], ctx["job_try"], ctx["redis"]) and anything you stashed there at startup (a DB session factory, an HTTP client). No ctx argument, no arq task.
The worker process itself is configured with a WorkerSettings class โ a list of task functions plus how to reach Redis. You run it as its own process (arq app.worker.WorkerSettings), completely separate from uvicorn running your API. That separation is the whole point: the API process can crash, deploy, or scale independently of the worker pulling jobs off the queue.