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

st.rerun not updating state of clicked button to false and entering an infinite loop #7662

Closed
4 tasks done
bonfire27 opened this issue Nov 2, 2023 · 4 comments
Closed
4 tasks done
Labels
status:needs-triage Has not been triaged by the Streamlit team type:bug Something isn't working

Comments

@bonfire27
Copy link

bonfire27 commented Nov 2, 2023

Checklist

  • I have searched the existing issues for similar issues.
  • I added a very descriptive title to this issue.
  • I have provided sufficient information below to help reproduce this issue.

Summary

In my code I generate/fetch some data in a part of the script and below I allow the user to edit this data which has to be passed back to the part above. Something like this:

Reproducible Code Example

import streamlit as st


def fetch_process_data(user_input):
    data = ["abc", "def"]
    processed = user_input if user_input is not None else data
    return data, processed


data, processed = fetch_process_data(st.session_state.get("user_input"))

st.session_state["edited"] = st.data_editor(processed)
if st.button("Save and run"):
    st.session_state["user_input"] = st.session_state["edited"]
    st.rerun()

st.write(data)
st.write(processed)

EDIT: just this already loops infinitely:

import streamlit as st

a = st.empty()
a.info("infinite")
if st.button("Save and run"):
    st.write("infinite")
    st.rerun()

a.info("stopped")

Steps To Reproduce

Click "save and run" in the script I provided. If you debug it you can verify the button doesn't change to false. At least on my machine.

Expected Behavior

The button should change to false after a rerun and stop the infinite loop

Current Behavior

The button doesn't update and the program goes inside the if statement over and over

Is this a regression?

  • Yes, this used to work in a previous version.

Debug info

  • Streamlit version:1.28.0
  • Python version: 3.10.12
  • Operating System: Windows 11 with WSL Ubuntu 22.04.3 LTS
  • Browser: Edge

Additional Information

No response

@bonfire27 bonfire27 added status:needs-triage Has not been triaged by the Streamlit team type:bug Something isn't working labels Nov 2, 2023
Copy link

github-actions bot commented Nov 2, 2023

If this issue affects you, please react with a 👍 (thumbs up emoji) to the initial post.

Your feedback helps us prioritize which bugs to investigate and address first.

Visits

@MarkDw123
Copy link

MarkDw123 commented Nov 2, 2023

I can confirm that issue, had to downgrade to 1.27.0 to get my app to work again. (tried on Windows and Linux, Python 3.11.6)

@benasse
Copy link

benasse commented Nov 2, 2023

hello,
I think this problem has already been reported, you can have a look:

@bonfire27
Copy link
Author

Already reported and fixed on #7643

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:needs-triage Has not been triaged by the Streamlit team type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants