Skip to content

Fix API requestor hanging when not using a global session #167

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

Merged
merged 1 commit into from
Jan 6, 2023

Conversation

ddeville
Copy link
Contributor

@ddeville ddeville commented Jan 6, 2023

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 ddeville requested a review from hallacy January 6, 2023 17:09
@ddeville ddeville force-pushed the damien/async-session-fix branch from 79ee0ba to 3c07c16 Compare January 6, 2023 19:57
@ddeville ddeville merged commit 7af43ce into main Jan 6, 2023
@ddeville ddeville deleted the damien/async-session-fix branch January 6, 2023 20:15
cgayapr pushed a commit to cgayapr/openai-python that referenced this pull request Dec 14, 2024
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.

2 participants