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

Fix trigger resets with fast reruns #7283

Merged
merged 5 commits into from Sep 13, 2023

Conversation

AnOctopus
Copy link
Contributor

@AnOctopus AnOctopus commented Sep 6, 2023

Describe your changes

Resetting trigger values of session state before we copy in the new client state. If fast reruns is enabled, the old script run can't do its on_script_finished cleanup, because it has been disconnected. For removing stale widgets, that is mostly not a problem, but failing to reset triggers basically prevents buttons from working until the script cleanly finishes. Resetting during on_script_will_rerun prevents this problem, making the behavior consistent with or without fast reruns.

GitHub Issue Link (if applicable)

Fixes #6643

Testing Plan

Verified with manual tests. I should probably add an e2e regression test for this.


Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

# Update ourselves with the new widget_states. The old widget states,
# used to skip callbacks if values haven't changed, are also preserved.
# Clear any triggers that weren't reset because the script was disconnected
self._reset_triggers()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As an alternative, I considered splitting on_script_finished in two, and calling the part with the trigger reset from request_stop, before the disconnect. I opted to do it here instead to be more sure that the reset will happen, and to avoid having to create a bunch of plumbing methods that now correspond to calling just one function on the actual session state.

@AnOctopus AnOctopus changed the title Fix trigger resets with fast reruns, and simplify some state handling Fix trigger resets with fast reruns Sep 8, 2023
@AnOctopus AnOctopus merged commit c777590 into streamlit:develop Sep 13, 2023
49 checks passed
@AnOctopus AnOctopus deleted the fix/fast-rerun-trigger-reset branch September 13, 2023 17:44
eric-skydio pushed a commit to eric-skydio/streamlit that referenced this pull request Dec 20, 2023
zyxue pushed a commit to zyxue/streamlit that referenced this pull request Mar 22, 2024
zyxue pushed a commit to zyxue/streamlit that referenced this pull request Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Button / st.session_state bug introduced with 1.20?
2 participants