streamlit icon indicating copy to clipboard operation
streamlit copied to clipboard

Page Refresh detection and data persistance between refresh page

Open learncodingforweb opened this issue 1 year ago • 2 comments

Checklist

  • [x] I have searched the existing issues for similar feature requests.
  • [x] I added a descriptive title and summary to this issue.

Summary

Currently,

  • There is no way to detect page refresh
  • There is no way to persists data between page refresh

Why?

I want to open serial port manually and it should be keep opened serial port object, even user press page refresh button on browser. secondly it should close it on page exist.

How?

Currently i am using @st.cache_resource to open it by opening fixed serial port and close it using atexit.register(app_closed)

Additional Context

No response

learncodingforweb avatar Jan 22 '25 16:01 learncodingforweb

To help Streamlit prioritize this feature, react with a 👍 (thumbs up emoji) to the initial post.

Your vote helps us identify which enhancements matter most to our users.

Views

github-actions[bot] avatar Jan 22 '25 16:01 github-actions[bot]

This is very important. We have tried using threads to handle long running process. When the page refreshes, the thread is also killed. We thought of using a persistent websocket connection but I think one the page is refreshed, the http session is renewed.

eaudet avatar Jun 09 '25 13:06 eaudet