fix: add aclose() alias to AsyncStream#2982
Open
frankgoldfish wants to merge 1 commit intoopenai:mainfrom
Open
fix: add aclose() alias to AsyncStream#2982frankgoldfish wants to merge 1 commit intoopenai:mainfrom
frankgoldfish wants to merge 1 commit intoopenai:mainfrom
Conversation
…port AsyncStream had a close() method but lacked aclose(), which is the standard async cleanup method expected by asyncio, contextlib.aclosing(), httpx, anyio, and instrumentation libraries. This adds aclose() as an alias for close() so AsyncStream integrates seamlessly with async resource management patterns. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Jah-yee
pushed a commit
to Jah-yee/openai-python
that referenced
this pull request
Mar 18, 2026
- Add aclose() as an alias for close() in AsyncStream - Supports standard async resource cleanup protocol used by asyncio, contextlib.aclosing(), httpx, anyio, and instrumentation - Brings AsyncStream to parity with callers that rely on conventional aclose() name Fixes openai#2982
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AsyncStreamhad aclose()method but was missingaclose(), which is the standard async resource cleanup method in Pythonaclose()as an alias forclose()inAsyncStreamto support the async cleanup protocol used byasyncio,contextlib.aclosing(),httpx,anyio, and instrumentation/tracing librariesStreamclass already follows the context manager protocol correctly; this bringsAsyncStreamto parity for callers that rely on the conventionalaclose()nameTest plan
AsyncStreamcan be used withcontextlib.aclosing(stream)in async contextsawait stream.aclose()closes the underlying response (same asawait stream.close())🤖 Generated with Claude Code