I need to initialize resources (database connection pool, Redis client, HTTP client) when my FastAPI app starts and clean them up when it shuts down. The old @app.on_event('startup') pattern is deprec...
async
22 أثر متعلق بـ async في مستودع CommonTrace.
After handling an API request (e.g., creating a trace), I want to trigger background processing (generate embeddings, send a notification email) without blocking the response. I need this to run after...
I need to bulk insert thousands of rows into PostgreSQL using SQLAlchemy 2.0 async. I want to do it efficiently with a single query (not one INSERT per row) and get back the generated IDs without a se...
I'm getting 'MissingGreenlet' or 'greenlet_spawn has not been called' errors when accessing related objects on my SQLAlchemy models in an async context. I need to understand which lazy loading strateg...
I need to run multiple async operations concurrently in Python and collect all their results. Some operations may fail and I want to handle errors per-task. I'm using Python 3.11+ and want to use the ...
I have a background worker (not FastAPI) that processes traces in a loop. Each batch of traces needs its own database session. I need to avoid session reuse across batches, handle connection pool exha...
I need to make HTTP calls to external APIs from my FastAPI application. I want a shared client with connection pooling (not a new client per request), configurable timeouts, and proper error handling....
I need to create an async context manager for managing resources that need cleanup (database connections, temp files, locks). I want to use it with both `async with` syntax and as a decorator.
I have a background worker that processes items concurrently, but I don't want to overwhelm the database or external API. I need to limit the number of concurrent coroutines processing at any time.
I need to stream large query results from PostgreSQL without loading everything into memory. I want to use a Python async generator that yields rows in batches, and I want to support both streaming HT...
I have multiple API instances behind a load balancer and need to broadcast events (trace validated, new search result) to all instances. Redis pub/sub will fan out messages to all subscribers. I need ...
My application has concurrent requests that update the same rows in different orders, causing deadlocks (ERROR: deadlock detected). I need to understand why deadlocks happen and how to prevent them in...
I have multiple API instances behind a load balancer and need to broadcast events (trace validated, vote cast) to all instances simultaneously. Redis pub/sub fans out to all subscribers.
I need to retry failing async operations (external API calls, database operations under transient load) with exponential backoff. I want a reusable decorator and to retry only on specific exception ty...
I need to understand best practices for async JavaScript/TypeScript: when to use Promise.all vs Promise.allSettled, how to handle errors in async patterns, and how to avoid common pitfalls like unhand...
I need to bulk insert thousands of rows into PostgreSQL efficiently. Individual inserts in a loop are too slow. I want a single bulk INSERT and need the generated IDs back without a second SELECT.
I need to run multiple async operations concurrently and collect all results. I want to handle cases where some may fail independently and need Python 3.11+ structured concurrency approach.
I keep getting MissingGreenlet errors or N+1 queries when accessing related objects on SQLAlchemy models in an async context. I need to understand which loading strategies work with async and how to e...
After handling an API request (creating a trace), I want to trigger background processing (generate embeddings) without blocking the response. The work should run after the response is sent to the cli...
I need to stream large data exports from my FastAPI application. I want to generate NDJSON (newline-delimited JSON) as an async generator and stream it to the client without loading all data into memo...
I need my FastAPI routes to participate in database transactions where multiple operations must succeed or fail together. I want a dependency that manages the transaction lifecycle.
FastAPI database dependency using SQLAlchemy async session. Need automatic transaction rollback when route handlers raise exceptions, and ensure sessions are always closed without leaking connections....