Is that a way to block the streamlit app re-run before the previous run finished?

My streamlit app is a little lit slow, when I click something, the re-run may take several seconds to finish. If user click something during the running period, it seems the streamlit will do the re-run immediately without waiting the previous run finished. is this understanding correct? if yes, is there any way to make sure the re-run only happened after the previous run is finished?

Hey @fanraul,

Do you know what is making your app a bit slow? Are you loading large models/data sets in? If you are you can use the @st.cache on the functions where its slow. It will still be a bit slow on the first load, but after that it will be speedy- as you won’t actually be reloading the slow bit each time.

Checkout the docs link here

If you have this already let me know and we can see if a different solution would work for you!

Happy Streamlit-ing!

Yes,I use cache a lot. I use streamlit to build a interface allow user insert/delete some data’s with some business logic. In case user click too quick,it will create some inconsistent data. So I would like to avoid user click before the processing is complete. Currently,I write a message in the end to notify user that the processing is finished.


So, I was thinking and what if you use a processing/ loading screen while your app is doing the run through the data? I dont have code snippets but it could look something like this:

import streamlit as st
import time

def big_data():

def more_data():

st.title("My Big Data App")

with st.spinner('In Progress'):
    st.success('Loaded Big_data')

    st.success('Setup complete')

a_button = st.button("Click me")

if a_button:

This way while the data is loading, people cannot press any buttons before the processing is complete.

Happy Streamlit-ing!