Hang/infinite loop when calling from Python

Hi all. I have coded a python script that launches a streamlit dashboard app. I have a GUI separately (coded in python) that calls that script when the user clicks a button. However, if the browser tab is closed (e.g. by pressing CTRL-W) the GUI hangs because the streamlit script is still running in the background. How do I get the script to stop if the browser tab is closed?

I should add that less technical solutions and hacks are encouraged as I don’t want to dig into Windows operations, etc. Thanks so much!

1 Like

Hi @ryanblumenow, and welcome to the Streamlit community! :balloon: :raised_hands:

I’m not aware of any way to programmatically close the terminal, however ctrl+c in terminal, shift+f5 if debugging, should work?


Hi Charly!

Thank you so much for the warm welcome :slight_smile: Great to be here.

Unfortunately I don’t think those mechanisms would work in my case because my GUI hangs when the script is still running but the browser tab is closed. This means that my users need to restart the whole system each time if that happens. They don’t have access to the terminal to stop the script.

Would love ideas on how to solve this :frowning: