Tagged articles
2 articles
Page 1 of 1
Code Mala Tang
Code Mala Tang
Jul 24, 2025 · Backend Development

FastAPI Async Pitfalls: When to Use BackgroundTasks, run_in_executor, or Celery

FastAPI’s async model excels with I/O‑bound tasks but can be crippled by CPU‑heavy or blocking code; this guide explains why, compares built‑in BackgroundTasks and run_in_executor, and shows when to offload work to dedicated queues like Celery or Dramatiq for reliable, scalable processing.

BackgroundTasksFastAPIPython
0 likes · 8 min read
FastAPI Async Pitfalls: When to Use BackgroundTasks, run_in_executor, or Celery
Code Mala Tang
Code Mala Tang
May 16, 2025 · Backend Development

How to Run Non-Blocking Background Tasks in FastAPI with BackgroundTasks

FastAPI’s BackgroundTasks feature lets you register functions that run after a response is sent, enabling non‑blocking operations such as sending emails, logging, or cleaning resources, with simple code examples, parameter details, and insights into its Starlette‑based implementation and limitations.

AsynchronousBackgroundTasksFastAPI
0 likes · 6 min read
How to Run Non-Blocking Background Tasks in FastAPI with BackgroundTasks