Hey @HHest
Hmmm, based on the error you are providing, it seems like it’s a web socket problem. Let me see if my colleague knows more what’s going on.
Hey @HHest
Hmmm, based on the error you are providing, it seems like it’s a web socket problem. Let me see if my colleague knows more what’s going on.
Thank you very much @kmcgrady. I’ll try to replicate with a small example as well.
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.
Any idea why that would be?
Thanks
That’s really awesome! Thanks for sharing will look into this idea
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
Amazing!!!!!
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,
appreciate any replies
Thank you
Hi all!
I’ve been using this component for some months now for a real-time dashboard i’ve been working on and it has been really helpful.
One thing I noticed, is how memory consumption increases as the interval parameter decreases. When the refresh rate is set to 1 min, memory consumption is around 150 mb on average no matter how long the app is running. When the dashboard refreshes every second, the memory consumption increases very fast. In about 4-5 hours it has reached close to 1.5 gb of memory consumption.
I’m trying to debug the issue, but I’m not sure where to start. Any ideas? The app is collecting data. It would be really helpful if the dashboard refreshed every second and let it run for days.
Maybe the python garbage collector doesn’t release memory when the dashboard refreshes too often (?)
Last, whenever I close the chrome tab and open a new one, the memory consumption goes down to 100-120 mb and the cycle repeats itself.
Hey @a.man
Sorry for the delay. I was out for the holidays.
Memory leaks can get very complicated. We have noticed in our testing that often the Python heap grows and doesn’t get cleared right away. We already run with the flag runner.postScriptGC to True, so every script run executes the garbage collector.
Are you 1. using the latest Streamlit, and 2. do you have any graphs from say memray that explain the memory consumption over time?
Thank you!
Hi, I have a question on how this works with st_cache_data.
I have an app that fetches data from a SQL database. The data is collected and used to create dashboards. The thing is that the database is constantly updated and I need the data in my app to update every 10 minutes to keep up.
For the data cache, I’m using st.cache_data(ttl=60). This way the data should be cached for 1 minute. For the refresh, I’m using st_autorefresh(interval = 600000, limit = None). This way the app refreshes every ten minutes.
Shouldn’t this method work? Shouldn’t the new data be fetched once the refresh is done? I’m asking because I’m not getting this result ![]()
It should work.
I do the same thing, but I always execute clear() on the cached function first.
I added st_autorefresh at the end of the script. You can try it out if it works.
Yes, I had to do the same thing and it worked.
Very nice and useful feature additions!
I have a scenario similar to the one described by @saitharun_gunasekar. I have a page with autorefresh enabled and in that page there is also a button that opens a dialog. When the dialog is open and the user is interacting with it an unorefresh happens and the dialog gets closed.
At the moment I have reduced the refresh interval to mitigate the issue but this does not really solves the porblem. It would be nice to be able to pause and resume the autorefresh on certain events or programmatically.
I’ve tried to re-create the timer with the same key when the dialog appears but I received a duplicate key error. It would be nice to be able to modify refresh intervals by re-executing st_autorefresh(…) with the same key.