Summary
How do I make my streamlit webapp timeout after certain time of inactivity by user on Windows & Unix systems.
Expected behavior:
User opens the webapp, leaves the tab running with no activity for some time. Streamlit script should close (st.stop() maybe) after a certain amount of time.
Debug info
- Streamlit version: 1.27.0
- Python version: 3.7.6
- Using Conda? PipEnv? PyEnv? Pex?
- OS version: Windows 10
- Browser version: Chrome 83.0.4103.116
Additional information
Since I couldnt find anything inbuilt related to this, i tried to find if i can timeout a function instead.
I found this stackoverflow thread which i thought could be useful.
Here, i found the 3rd highest answer by user “Russia Must Remove Putin”
His solution involved using a @exit_after decorator to timeout a function.
While this solution did work somewhat it isnt what i intended to do. When i used this decorater, instead of timing out that particular function which it wrapped around & stopping its execution. It stopped the whole Streamlit app running in my terminal.
I had to run the command “streamlit run my_file.py” to get it back up.
What i need is for the streamlit script to run the st.stop() command after certain minutes of inactivity by user.