Skip to content

Conversation

@vdonato
Copy link
Collaborator

@vdonato vdonato commented Nov 28, 2022

Note:

  • This PR is going into the develop branch rather than feature/session-manager as it doesn't hurt
    to merge it into develop and reduces the diff size of the feature branch.
  • No functional change is introduced by this PR.

📚 Context

In the feature/session-manager branch, we're working towards improving the way that we handle
websocket disconnects. As part of this work, we'll need to have the final steps of AppSession
cleanup (done by the shutdown() method) happen when a session is garbage collected rather
than when the browser's websocket connection is dropped.

To make this easier, this PR splits out file changed handler registration/deregistration into two helper
methods. We also add a __del__ method to AppSession, which calls the shutdown() method on
garbage collection.

Finally, we add a test to make it harder to introduce AppSession-related memory leaks related to file
watchers holding references to AppSession file changed handler methods. This exact issue has
caused memory leaks in the past, so we should be extra-careful to avoid it given that our work to
defer AppSession cleanup is particularly prone to running into this.

  • What kind of change does this PR introduce?

    • Refactoring
    • Other, please describe: Prep work for upcoming feature

🧪 Testing Done

  • Added/Updated unit tests

@vdonato vdonato added the security-assessment-completed Security assessment has been completed for PR label Nov 28, 2022
@vdonato vdonato force-pushed the watcher_disconnect_reconnect branch from a452cbd to eadbfbe Compare November 28, 2022 22:46
@vdonato vdonato force-pushed the watcher_disconnect_reconnect branch from eadbfbe to fd737b2 Compare November 29, 2022 01:30
@vdonato vdonato merged commit d635983 into streamlit:develop Nov 29, 2022
@vdonato vdonato deleted the watcher_disconnect_reconnect branch November 29, 2022 02:19
tconkling added a commit to tconkling/streamlit that referenced this pull request Nov 29, 2022
* develop:
  Use newer annotations features in caching modules (streamlit#5738)
  Add links for workflow failure slack messages (streamlit#5772)
  Refactor AppSession to simplify improving reconnect behavior (streamlit#5782)
  Fixing component-template typecheck failure (streamlit#5780)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

security-assessment-completed Security assessment has been completed for PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants