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?

Best,
Charly

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: