Hi everyone, I am new to streamlit and I just wanted to thank you for this great tool.
I deployed my app (and kept it private) to the streamlit cloud. everything was working fine. but I noticed a weird behavior which is that the app resets to the app initial state if my laptop goes to sleep or even if I am using my laptop but not the app itself.
I have looked at this post to solve the resetting problem due to laptop sleep. and this solution worked for me. but the resetting problem due to not using the app itself still exists.
any thoughts on what causes this problem and how to avoid it.
If not mistaken, Streamlit has a idle timeout settings, and if you want the app to be awake, you can try running a script that pings your app periodically
Thank you for your response, but do you happen to know if it’s possible to change this idle timeout settings. also, it would be much appreciated if you could give me some pointers on how to right a script that pings the app periodically.
Don’t think it is possible to change the idle timeout settings since if there is an inactivity, the websocket will automatically be closed.
Thinking maybe a simple script like this could allow you to ping the app periodically:
import time
import requests
def ping_app(url):
while True:
try:
requests.get(url)
except requests.exceptions.RequestException as e:
print("Error pinging the app:", e)
time.sleep(300) # Ping the app every 5 minutes
# Start the ping-to-keep-alive mechanism in a separate thread
app_url = "https://your-streamlit-app-url"
threading.Thread(target=ping_app, args=(app_url,)).start()
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.