in the application I’m currently working on I observe that the program runs multiple times on startup. This behavior even occurs when starting the simplest possible program (print statement is executed multiple times):
import streamlit as st
print("new run")
When refreshing the page, the print statement is executed once (as expected).
Thank you for your answer. Upgrading to v1.29.0 unfortunately didn’t solve the issue. The amount of program runs is random, sometimes the program runs once after starting (as expected) but sometimes it runs twice or more often.
I tried multiple times and each time the script ran only once. We must be doing something different from each other but I don’t know what it can be. Can you reproduce the issue in streamlit cloud?
Do you mean Streamlit Community Cloud? When deploying an app there, is there an opportunity to see e.g. print statements? Because otherwise I won’t see if the programs runs multiple times (it has no visual effect, I just see this behavior in the console).
I have the same issue. After a bit of debugging it appears that the dashboard runs twice on startup, on two different threads concurrently (thread ids are different).
Just to say that the issue still happens with 1.36.0
At First launch, the page is run many times, sometimes 7 times.
When refreshing the browser page, only one run as expected.
I run into the same issue in my local development environment: The PID of the process is the same, but the code is executed by three different threads.
I usually start the application as follows:
Whenever you press Ctrl+C to stop the application, make sure to close inactive tabs that are open in your browser. This issue occurs because when you run the application, old tabs refresh, resulting in the same number of new runs being printed as the total number of Streamlit windows opened in the browser.