Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure Document and Location models are garbage collected #1407

Merged
merged 1 commit into from
Jun 12, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions panel/viewable.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,10 +399,9 @@ def _cleanup(self, root):
root: bokeh.model.Model
Bokeh model for the view being cleaned up
"""
if root.ref['id'] in state._handles:
del state._handles[root.ref['id']]
if root.document in state._locations:
del state._locations[root.document]
ref = root.ref['id']
if ref in state._handles:
del state._handles[ref]

def _preprocess(self, root):
"""
Expand Down Expand Up @@ -544,8 +543,16 @@ def _server_destroy(self, session_context):
Server lifecycle hook triggered when session is destroyed.
"""
doc = session_context._document
self._cleanup(self._documents[doc])
root = self._documents[doc]
ref = root.ref['id']
self._cleanup(root)
del self._documents[doc]
if ref in state._views:
del state._views[ref]
if doc in state._locations:
loc = state._locations[doc]
loc._cleanup(root)
del state._locations[doc]

#----------------------------------------------------------------
# Public API
Expand Down