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

Fix API requestor hanging when not using a global session

Open ddeville opened this issue 2 years ago • 0 comments

When a global session wasn't set in openai.aiosession, we would create a temp ClientSession on the fly. Unfortunately, this session wasn't scoped correctly since it was closed upon returning from arequest_raw but _interpret_async_response would later call await result.read() on the response, which would hang since the backing session had already been closed.

This patch ensures that the session is kept open for the duration of the request and the entire parsing of the response.

ddeville avatar Jan 06 '23 17:01 ddeville