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.
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.