openai-python icon indicating copy to clipboard operation
openai-python copied to clipboard

Connections aren't being closed

Open dougli opened this issue 1 year ago • 3 comments

The library uses requests to fetch data from OpenAI servers, but we never call .close() on those connections which leaves dangling open file handles on the OS.

Can we clean these connections up gracefully, either after a period of time, or after making a request? There is an advantage to leaving it open as it doesn't have to do the HTTPS handshake on every request, but we should clean this up properly after a period of idleness.

This bug interacts very poorly with another bug in Docker Desktop -- https://github.com/moby/vpnkit/issues/587; the openai library stops working entirely after running it in a Docker container on Mac / Windows for a few minutes. All requests to OpenAI servers time out indefinitely.

dougli avatar Nov 24 '22 14:11 dougli