I’ve made a monitoring program to monitor my servers by using Visdom. It’ve been working quite well.
Now, I’m trying to implement the monitor by Streamlit.
The monnitor works by using a endless loop with a
st.rerun with a sleep also works).
However, the main issue is that when user open a new session, a new loop will be created and never end then. Is there any solution to terminate the newly created session? Or prevent creating a new session, just use the existed one.
Simple dashboard snippet is shown below:
import streamlit as st import time import random from streamlit.runtime.scriptrunner import get_script_run_ctx # values cannot be used in st.session_state!! if 'my_values' not in st.session_state: st.session_state.my_values = list() if not st.session_state.my_values: st.session_state.my_values.append(0) st.line_chart(st.session_state.my_values[-100:]) new_value = st.session_state.my_values[-1] + random.randrange(-100, 100) / 100 st.session_state.my_values.append(new_value) time.sleep(1) ctx = get_script_run_ctx() print(ctx.session_id) #<- print session-id endlessly st.experimental_rerun()
Thank you so much.