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.
thanks
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()
Thank you very much for your help, I will try your suggestion and let you know.
Unfortunately I tried the Idea of running a script that pings my app to keep it awake and it did not work.