Skip to content

Instantly share code, notes, and snippets.

@CodeWithOz
Last active October 9, 2025 05:36
Show Gist options
  • Select an option

  • Save CodeWithOz/d31e788d4bec21eec47a3247e593163e to your computer and use it in GitHub Desktop.

Select an option

Save CodeWithOz/d31e788d4bec21eec47a3247e593163e to your computer and use it in GitHub Desktop.
Code snippets showing different approaches to resolving blocking operations in a FastAPI server.
...
from fastapi.background import BackgroundTasks
...
@app.get("/process-files")
async def process_files(background_tasks: BackgroundTasks):
logger.info("Before process files")
background_tasks.add_task(upload_to_s3)
logger.info("After process files")
return {"ok": True}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment