Skip to content

fix(streaming): add aclose() alias to AsyncStream - #2954

Closed
mvanhorn wants to merge 1 commit into
openai:mainfrom
mvanhorn:osc/2853-asyncstream-aclose
Closed

mvanhorn wants to merge 1 commit into
openai:mainfrom
mvanhorn:osc/2853-asyncstream-aclose

Conversation

@mvanhorn

Copy link
Copy Markdown

Fixes #2853

Problem

AsyncStream exposes close() but not aclose(), causing AttributeError when callers use the standard Python async cleanup convention (await stream.aclose()). This surfaces with instrumentation libraries (e.g. Langfuse) that wrap the raw stream.

Fix

Added aclose() as an alias for close() on AsyncStream, following the standard Python async resource convention (PEP 525, used by asyncio, httpx, etc.). Note that AsyncStream.close() already internally calls self.response.aclose().

This contribution was developed with AI assistance (Claude Code).

AsyncStream exposes close() but not aclose(), causing AttributeError
when callers use the standard Python async cleanup convention. This
surfaces with instrumentation libraries (e.g. Langfuse) that wrap
the raw stream and call aclose().

Fixes openai#2853

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

Copy link
Copy Markdown
Contributor

Thanks for the contribution, and sorry for the delay! This is now covered by #2854, so I’m closing this PR.

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.

AsyncStream missing aclose() causes AttributeError in streaming structured output

2 participants