Implement starting and stopping a Python background script

  1. Are you running your app locally or is it deployed?
    locally

  2. Share the Stream list and Python versions.
    Python v.3.11
    Streamlit v. 1.28.0

Greetings!
I want to implement starting and stopping a Python background script (my_script.py).
using the radio button (st.radio())
my_script.py uses an infinite “while” loop inside itself.
Tell me, please, how to do it correctly.

Hi @Eugeny

There’s a st.stop() (st.stop - Streamlit Docs) that you might want to look into.

You could also use callback functions (on_click) together with st.button().

There was also a related forum post that contains a solution code snippet that may give you some additional ideas:

Hope this helps!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.