RFC Registry/RFC-003
RFC-003backendFinal
FastAPI Core Ecosystem Standard

FastAPI & Pydantic v2 Async Concurrency Non-Blocking Guarantee

Prohibits blocking I/O calls (e.g. requests, time.sleep) inside async def endpoints, mandating httpx.AsyncClient or asyncio.to_thread to maintain single-thread event loop responsiveness.

Authors:Tiangolo (Sebastián Ramírez), AgentRules Systems Working Group
Version:v1.0.2
Last Ratified:2026-02-18

RFC-2119 Invariant Mandates

The keywords “MUST”, “MUST NOT”, and “SHOULD” in this document are to be interpreted as described in BCP 14 / RFC 2119.

MUST NOTClause 1

Async route functions ('async def') MUST NOT invoke synchronous blocking network calls (requests.*, urllib) or blocking file operations.

Engineering Rationale:Python's asyncio operates on a cooperative single-threaded event loop. Blocking calls stall all concurrent HTTP requests across the entire uvicorn worker.
Failure Blast Radius:Catastrophic latency spikes (p99 > 30s) and timeout failures under minimal concurrency.
MUSTClause 2

Outbound HTTP requests inside async def endpoints MUST utilize httpx.AsyncClient() with explicit connection pooling and timeout budgets.

Engineering Rationale:Async HTTP clients yield execution back to the loop during I/O waits.
Failure Blast Radius:Guarantees sustained 10,000+ rps concurrency without worker thread starvation.
MUSTClause 3

Pydantic v2 models MUST use model_validate() instead of deprecated parse_obj(), and model_dump() instead of dict().

Engineering Rationale:Pydantic v2 core is written in Rust; legacy v1 methods trigger backward compatibility shims that degrade throughput by 5x.
Failure Blast Radius:Performance degradation and deprecation warnings in Python 3.12+.

Complete RFC Specification Document

IETF Formal Markdown Format
# RFC-003: FastAPI & Pydantic v2 Async Concurrency Invariants

## 1. Event Loop Integrity
In FastAPI applications:
```python
# COMPLIANT:
@router.get("/data")
async def get_data():
    async with httpx.AsyncClient(timeout=5.0) as client:
        res = await client.get("https://api.internal/data")
        return res.json()

# FORBIDDEN (Violates RFC-003):
@router.get("/data")
async def get_data():
    res = requests.get("https://api.internal/data") # Freezes worker!
    return res.json()
```

Community Consensus Rating

Do these behavioral constraints represent the highest engineering standard for your team?

97% Consensus