Hmm @Bibek_Behera. Taking 15-20 min for the component to load is rather unusual. Is there anything you are doing that suggests longer times? Is the network connection less strong for example?
Itâs possible infinite refresh is not possible as it requires the Streamlit app to maintain its connection, which is not always the case.
Actually the component loading is fine. Currently my issue is dependency on the browser. I have to keep it open and hence my laptop canât shut down as well. Is there a way to open the tab from a terminal background.
So thereâs two solutions I can think of: an easy one, and a harder one.
The easiest one is using st.experimental_memowith a ttl. This will allow every new rerun past a certain time to extract the contents. Depending on how âup to dateâ the frontend has to be, you can use autorefresh every minute and have the ttl every 30 minutes, so itâs at most a minute delayedâŠor you can do 15 minutes and itâs at most 15 minutes delayed etc. A well-cached (or memoâed) information makes a rerun look seamless, so this would be my preferred approach.
The would not work if the effort is extremely time consuming or if you are really looking for very up-to-date information. Thereâs possible solutions to modify streamlit-autorefresh to have it call on the time marker (every half hour for example) and the ttl and get close and at least sync more clearly. The other option is to run some background job on a thread, but Streamlit is not super well-designed for that.
I saw this and wanted to use it for my app, which requires a live update every few minutes. However, I get this message when I try to run your trivial example.
I am getting this error when using autorefresh. My frequency is 1 sec.
The autorefresh works well for a while, then it starts giving the following error about âtoo many open filesâ, with the file name being the url that I have open. If it matters any, I am using the âpagesâ feature of Streamlit, and the url is one of the pages in question.
The other strange thing is that, this works fine on my local session of Streamlit, but when I push it to our AWS EC2 instance, the error starts appearing.
Hope you will have time to respond. Thank you very much.
streamlit version 1.17.0
2023-01-24 19:23:05.090 Exception in callback BaseAsyncIOLoop._handle_events(10, 1)
handle: <Handle BaseAsyncIOLoop._handle_events(10, 1)>
Traceback (most recent call last):
File â/usr/lib/python3.7/asyncio/events.pyâ, line 88, in _run
File â/opt/myapp/lib/python3.7/site-packages/tornado/platform/asyncio.pyâ, line 206, in _handle_events
File â/opt/myapp/lib/python3.7/site-packages/tornado/netutil.pyâ, line 267, in accept_handler
File â/usr/lib/python3.7/socket.pyâ, line 212, in accept
OSError: [Errno 24] Too many open files
Hi @kmcgrady, will this solve the auto refresh issue of app on streamlit cloud? If I add st_autorefresh(interval=8*60*60*1000, key="no_update_for_8h"), will this avoid auto refresh issue for 8h for the deployed app on cloud?
Assuming you do not use the component, this would not fix the auto refresh issue. This might be a Streamlit cloud challenge. I believe the issue got a comment that explains this.
Hi @kmcgrady
I know this was design for streamlit, which I was using with great happiness, but now I started using it with plotly-dash, and it makes the color of the bars black, when I remove it, the colors are back, I am working on Python 3.9.
Hey @arafeek . I have not played with plotly dash, so I do not know. Is there a way for Plotly Dash to support Streamlit custom components? I wasnât aware of any way. If you can point me to a resource, I am happy to look into it.
Hi again,
Thanks for the prompt response, I actually just discovered that this will happen simply by importing the module, all you need is to add
from streamlit_autorefresh import st_autorefresh
After that, you will be stuck, restarting the kernel does not reset the colors, nor deleting the variables. I am using Spyder (the latest) with Python 3.9, and the only way to have the colors back is by starting a new file and copy the code (without this import)
That is so weird, but honestly, I donât think it will properly work in plotly dash. This component sends a streamlit specific message to the frontend, and the autorefreshing is triggered from the frontend. It even requires Streamlit under the hood. I cannot see (from my searching) how it would work properly (impressed it wonât even error).
I wish I could help. Iâd probably look at the Plotly Dashâs Live Updating mechanism
hi @kmcgrady
I am developing a streamlit application that displays data that changes for every n minutes i used st_autorefresh to rerun my code after that n minute interval , but if there is any user_interaction between that n minutes (suppose take the user-interaction was at n-2 minutes) the code is being runned at n minutes after the user interaction and not at n before the user interaction , can anyone please provide a solution for this,
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.