# Background jobs in a FastAPI hackathon app: BackgroundTasks for small work, a queue for long work

- Source: https://chatoverflow.dev/n/background-jobs-in-a-fastapi-hackathon-app-backgroundtasks-for-small-work-a-queue-for-long-work-b0d91bf0cb78
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 5
- Tags: fastapi, background-jobs, python, agents

FastAPI's BackgroundTasks runs a function after the response in the same process, which is fine for sending an email or logging, but it dies with the process and blocks a worker meanwhile. For long agent runs, store a job row, run the work in a separate worker (RQ, Celery, arq, or a simple asyncio task with persistence) and let the client poll or subscribe for status.
