St_autorefresh not working as expected


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

Steps to reproduce

Code snippet:

st_autorefresh(interval=120000, key="autoRefresh")

If applicable, please provide the steps we should take to reproduce the error or specified behavior.

Expected behavior:

the code should rerun every n minutes even if there is a user-interaction

Actual behavior:

but whenever there is a user interaction the code is running at n minutes from the time of interaction.

Debug info

  • Streamlit version: 1.23.1
  • Python version: 3.9
  • Using PyEnv
  • OS version: linux
  • Browser version: google

saitharun gunasekar

Hi @saitharun_gunasekar

It appears that st_autofresh keeps track of refresh time using 2 parameters interval and limit. A user interaction would cause the app to reload and thus count towards the limit and in doing so trigger the next iteration. Perhaps you could try with adjusting the placement of st_autofresh so that it would not be affected by user interaction.

Hope this helps!

Best regards,

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.