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

Fixes streaming event race condition #7926

Merged
merged 2 commits into from Apr 4, 2024
Merged

Conversation

aliabid94
Copy link
Collaborator

Happened because of how we were closing event streams. Added a test that blasts lots of events rapidly so we don't run into this again. Test by running demo/rapid_generation on main and this branch.

Fixes: #7921

@gradio-pr-bot
Copy link
Contributor

gradio-pr-bot commented Apr 4, 2024

🪼 branch checks and previews

Name Status URL
Spaces ready! Spaces preview
Website ready! Website preview
Storybook ready! Storybook preview
🦄 Changes detecting...

Install Gradio from this PR

pip install https://gradio-builds.s3.amazonaws.com/9d8da6384503bddbe8ee5097489d1f93f5e388db/gradio-4.25.0-py3-none-any.whl

Install Gradio Python Client from this PR

pip install "gradio-client @ git+https://github.com/gradio-app/gradio@9d8da6384503bddbe8ee5097489d1f93f5e388db#subdirectory=client/python"

@gradio-pr-bot
Copy link
Contributor

🦄 change detected

This Pull Request includes changes to the following packages.

Package Version
@gradio/client patch
gradio patch
  • Maintainers can select this checkbox to manually select packages to update.

With the following changelog entry.

Fixes streaming event race condition

Maintainers or the PR author can modify the PR title to modify this entry.

Something isn't right?

  • Maintainers can change the version label to modify the version bump.
  • If the bot has failed to detect any changes, or if this pull request needs to update multiple packages to different versions or requires a more comprehensive changelog entry, maintainers can update the changelog file directly.

Copy link
Collaborator

@freddyaboulton freddyaboulton left a comment

Choose a reason for hiding this comment

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

Nice fix @aliabid94 !

@yvrjsharma
Copy link
Collaborator

I can confirm that I no longer see the issue in the duplicated (private atm) mPLUGOwl/Doc Space when using the gradio wheels from this PR. Thanks @aliabid94 !

@pngwn
Copy link
Member

pngwn commented Apr 4, 2024

Can you explain what the race condition is here? It isn't obvious from the code or tests.

Copy link
Member

@pngwn pngwn left a comment

Choose a reason for hiding this comment

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

Looks good otherwise! Thanks @aliabid94!

@aliabid94
Copy link
Collaborator Author

race condition was that sometimes the client would receive the close_stream event from the backend before it had finished processing pending callbacks. This would cause the callback to be called with close_stream, but we shouldn't be calling the callback with that message, as would cause issues with apply_diff_stream

@aliabid94 aliabid94 merged commit 9666854 into main Apr 4, 2024
7 of 8 checks passed
@aliabid94 aliabid94 deleted the fix_rapid_generation_issue branch April 4, 2024 19:39
@dawoodkhan82
Copy link
Collaborator

Thanks for fixing @aliabid94

@keenranger
Copy link

This helped me streaming agent a lot! TY!

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.

Button name changes to undefined
7 participants