Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Periodically close open request.Sessions to avoid buggy interaction with Docker Desktop #478

Merged
merged 2 commits into from
Jun 6, 2023

Conversation

jhallard
Copy link
Contributor

@jhallard jhallard commented Jun 5, 2023

This PR fixes #140 by forcing open Sessions to be closed periodically (every 3 minutes at most). This PR also changes the rendering of API responses to maintain the sorting provided by the backend.

…ndle issues (#179)

As reported from the field - we create a `requests.Session` object on first request to the servers and then reuse it indefinitely. This can leave some open
file handles on the OS (not a big deal), but can interact poorly with a bug in Docker Desktop which causes the SDK to entierly break connections to the server.
See #140 for more info.
* [EZ] Remove sort-by-key when rendering JSON responses

The order of items in the API responses is intentional, and this order is clobbered by the rendering of `OpenAIObject`. This change removes the alphabetic sort
of response keys

* [EZ] Add unit test for new case

* Lint/fmt fixes

* Bleh isort

* Remove `internal_metrics` field
@jhallard jhallard merged commit 77e5cf9 into main Jun 6, 2023
@jhallard jhallard deleted the jhallard/cycle-open-sessions branch June 6, 2023 00:23
@FrogWan
Copy link

FrogWan commented Aug 22, 2023

When use multi processing in docker desktop, we are also facing connection abort issue. I have another PR to fix it. #579 Could you help to review?

megamanics pushed a commit to devops-testbed/openai-python that referenced this pull request Aug 14, 2024
… with Docker Desktop (openai#478)

* Periodically refresh open `requests.Session`s to mitigate open filehandle issues (openai#179)

As reported, we create a `requests.Session` object on first request to the servers and then reuse it indefinitely. This can leave some open file handles on the OS (not a big deal), but can interact poorly with a bug in Docker Desktop which causes the SDK to entierly break connections to the server.
See openai#140 for more info.

The order of items in the API responses is intentional, and this order is clobbered by the rendering of `OpenAIObject`. This change removes the alphabetic sort of response keys
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Connections aren't being closed
3 participants