Skip to content

Commit

Permalink
Ensure Document and Location models are collected
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Jun 12, 2020
1 parent d4375db commit 2bc842f
Showing 1 changed file with 12 additions and 5 deletions.
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

0 comments on commit 2bc842f

Please sign in to comment.