Skip to content
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

Stream with event queue #38996

Open
wants to merge 1 commit into
base: feature/azure-ai-projects-beta5
Choose a base branch
from

Conversation

jhakulin
Copy link
Member

@jhakulin jhakulin commented Dec 27, 2024

Added the _event_queue in stream handling because anext is designed to produce only one event (or item) per iteration. If the response stream delivers multiple events within a single chunk of data, we would need to queue up all those events and then return them one-at-a-time in subsequent calls to anext. Otherwise, if we return the first parsed event and discard the rest in that same call leads to lost events.

@azure-sdk
Copy link
Collaborator

API change check

API changes are not detected in this pull request.

if self.buffer:
event = await self._process_event(self.buffer)
self.buffer = "" # we've parsed it
if event:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can modify _process_event to return without Optional and eliminate the if event check here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants