fastapi-async-resilience
/fastapi-async-resilience
Audytuje asynchroniczne aplikacje FastAPI pod kątem blokującego I/O, wyczerpania pętli zdarzeń, wyścigów, limitów czasu i walidacji Pydantic.
- Autor
- marceloasl99 ↗
- Repozytorium
- canonical-rag ↗
- Licencja
- MIT
- Ostatnia zmiana repozytorium
- 01.11.2026
Ocena i bezpieczeństwo
- Pliki w paczce
- 1
- Skrypty
- 0
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 0
Brak sygnałów. Repozytorium zmienione 01.11.2026, bez odwołań do wycofanych modeli i API.
MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.
Co robi i kiedy
Audytuje asynchroniczne aplikacje FastAPI pod kątem blokującego I/O, wyczerpania pętli zdarzeń, wyścigów, limitów czasu i walidacji Pydantic.
Oryginalny opis (EN)
Audits FastAPI async backend applications for blocking I/O, event loop starvation, concurrency race conditions, thread pool offloading, timeout management, error middleware, and Pydantic validation resilience. Use when reviewing backend services, API endpoints, or asynchronous task execution.
Jak działa
- Core Review Areas
Podgląd SKILL.md
---
name: fastapi-async-resilience
description: >-
Audits FastAPI async backend applications for blocking I/O, event loop starvation,
concurrency race conditions, thread pool offloading, timeout management, error middleware,
and Pydantic validation resilience. Use when reviewing backend services, API endpoints,
or asynchronous task execution.
---
# FastAPI Async & Concurrency Resilience Skill
This skill guides deep code reviews and performance audits for FastAPI asynchronous services, with particular emphasis on preventing event loop starvation when combining CPU-bound ML models and disk-bound databases.
## Core Review Areas
### 1. Event Loop Starvation & Blocking Calls
- **CPU-Bound Models (ONNX, Cross-Encoders)**: CPU inference functions (such as `rerank(...)`) are synchronous and computationally intensive. If called inside an `async def` endpoint without `asyncio.to_thread` or a `ThreadPoolExecutor`, they freeze the entire FastAPI event loop, blocking all concurrent HTTP requests.
- **SQLite / Disk I/O**: SQLite calls (`db.execute`, `fetchall`) perform blocking file I/O. In high-concurrency environments, audit whether database access should be wrapped in worker threads or an async driver (`aiosqlite`).
- **Synchronous HTTP Clients**: Ensure external API calls use `httpx.AsyncClient` or `aiohttp` instead of synchronous `requests` or blocking socket calls.
### 2. Connection Pooling & Resource Cleanup
- **HTTP Client Lifecycles**: Verify that `httpx.AsyncClient` instances are reused across requests (e.g. via FastAPI app `lifespan` context manager) rather than instantiated per-request, preventing socket exhaustion.
- **Database Connection Leaks**: Check that SQLite connections or cursor contexts use `with sqlite3.connect(...) as conn:` or deterministic `try ... finally: conn.close()` blocks.
### 3. Request Validation & Error Handling
- **Pydantic Model Constraints**: Validate that input fields have reasonable limits (e.g. `query: str = Field(..., max_length=2000)` to prevent DoS memory allocations).
- **Graceful Error Responses**: Ensure unhandled exceptions return structured JSON payloads (`{"error": "...", "detail": "..."}`) rather than generic 500 HTML error pages.
- **Cancellation & Timeouts**: Verify that long-running operations specify request timeouts (`httpx.Timeout(60.0)`) and respect client disconnection signals.
Wersje
W bazie nie ma innych skilli o nazwie fastapi-async-resilience.
Migawka bazy z 13.11.2026 · wersja paczki 24c0d83c5b6d (skrót SHA-256 całej paczki)
Pobrania w ostatnich 30 dniach: 0 · ranking
Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.
Podobne skille
- 100python-fastapi-pydantic
Buduje asynchroniczne REST API w FastAPI z walidacją Pydantic i dokumentacją OpenAPI. - 100fastapi-expert
Wspiera tworzenie wydajnych API w FastAPI z obsługą async, REST, OpenAPI i Pydantic. - 100fastapi-patterns
Buduje produkcyjne aplikacje FastAPI z wstrzykiwaniem zależności, middleware, zadaniami w tle i uporządkowanym układem projektu, z wzorcami async, Pydantic, OpenAPI i testami. - 100fastapi-pro
Buduje szybkie asynchroniczne API w FastAPI, SQLAlchemy 2.0 i Pydantic V2, także mikrousługi i WebSockety. - 100fastapi
Obejmuje FastAPI: modele Pydantic, wstrzykiwanie zależności, asynchroniczny dostęp do bazy, zadania w tle, WebSocket i testowanie. - 100fastapi-pro
Podaje produkcyjne wzorce FastAPI dla Pythona 3.11+: endpointy async, SQLAlchemy 2.0 async, Pydantic V2, wstrzykiwanie zależności, JWT i testy.