Skip to content

httpx.PoolTimeout occurs frequently with SyncClient #821

Open
@domenicrosati

Description

@domenicrosati

Confirm this is an issue with the Python library and not an underlying OpenAI API

  • This is an issue with the Python library

Describe the bug

httpx.PoolTimeout occurs frequently with SyncClient

Recently, we noticed a high number of timeouts. Many requests were getting stuck on the default timeout of 600.
This was before we migrated.
We migrated to v1.2.3 to try to mitigate this but the requests were still getting stuck in timeout.
We have managed to mitigate this a little bit by setting the timeout to 30 seconds and retrying (without our own retry library since the OpenAI retries don't appear to have jitter or exp backoff and were causing problems at scale)
Now we are getting httpx.PoolTimeout when using the SyncClient. This is causing downstream issues since tasks start to pile up and we just get tons of httpx.PoolTimeout.

I think we will consider using a custom http client, though I noticed this requests being stuck in timeout on the old version of the api as well... which was our original motivation to migrate...

In case it helps this is in a production app doing about 3-6 OpenAI requests per second and seems to line up with busier traffic moments.

To Reproduce

  1. Use SyncClient
  2. Make 3-6 requests per second to ChatCompletions endpoint
  3. Get httpx.PoolTimeouts

Code snippets

No response

OS

ubuntu

Python version

Python v3.10.8

Library version

OpenAI v1.2.4

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions