Menu

httpx.PoolTimeout: Why Your Async Python Client Runs Out of Connections (and How to Fix It)
📰

httpx.PoolTimeout: Why Your Async Python Client Runs Out of Connections (and How to Fix It)

DEV Community: backend·Libme·19 days ago
#lIey7pbS
#devtobackend#devto#dev#httpx#client
Reading 0:00
15s threshold

httpx.PoolTimeout means a request waited for a free connection in the client's pool and never got one before the pool timeout expired. The server is usually fine. The cause is almost always one of three things: you fire more concurrent requests than the pool allows, you leak responses by never closing them, or you create a client per request and defeat pooling altogether. The fixes are a semaphore, async with on streams, and one shared client.

What does PoolTimeout actually mean?

The traceback looks like this:

httpx.PoolTimeout

Enter fullscreen mode

Exit fullscreen mode

Often it has no message at all, which is why people go hunting in the network layer. It is different from ConnectTimeout (TCP handshake too slow) and ReadTimeout (server too slow to send bytes).…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.