Will It Vibe logoWill It Vibe?
FASTAPI-001Medium severity-8 points

time.sleep() inside an async route handler

Part of Code Quality & Syntax, which counts for 20% of the overall score. When this check fires it deducts 8 points from that category, once per scan, no matter how many places it turns up.

What it detects

time.sleep() blocks the OS thread running the asyncio event loop, so every other request being served by that worker stalls for the full duration of the sleep, not just this request.

Why it matters

FastAPI runs all of your async def handlers on one event loop thread per worker. A blocking time.sleep() call freezes that whole thread, so every other request the worker is currently handling waits behind it, even requests that have nothing to do with this route. Under real traffic this turns one slow endpoint into a latency spike for the entire service.

How to fix it

Replace time.sleep(n) with await asyncio.sleep(n) inside async def handlers. If the delay is simulating work for a background job rather than the request itself, move it into a BackgroundTasks callback or a proper task queue (Celery, arq, RQ) instead of sleeping inline.

The paid report includes a ready-to-paste prompt for your AI coding agent for every check it finds, pointed at the exact findings from your scan. See pricing

Does your repo trip this check?

Paste a GitHub URL or drop a project folder. Scans run in your browser and take seconds.

Scan your repo

Related Code Quality & Syntax checks