openai-python
openai-python copied to clipboard
Fix API requestor hanging when not using a global session
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.