I use streamlit with infinite loop for taking data.
before loop I created button.
button have long waiting time inside
after button finish work it should compare actual data with data on start.
problem my algorithm have memory about data before pressing button, but not current.
which options I have?
It look like need multithreading or something similar?
because button freese streamlit on time of work
or is here other ways?
It may be helpful to share a code snippet so that others in the community could get a better idea on the specifics of the implementation that you have in mind.
below approximate example.
need press button before value is 100.
my real data was changed in time of button execution, same like in this script
I would like to see
True
False
but now I have
True
True
upd:
import streamlit as st
import time
if "is_initialized" not in st.session_state or False:
st.session_state.current_value = 0
st.session_state.LIMIT = 20
st.session_state.is_initialized = True
# need press button before current value more than 100
if st.sidebar.button("button"):
st.write(st.session_state.current_value < st.session_state.LIMIT)
time.sleep(8)
st.write(st.session_state.current_value < st.session_state.LIMIT)
with st.empty():
while True:
st.write(st.session_state.current_value)
time.sleep(0.01)
st.session_state.current_value += 1
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.