Merge pull request #6216 from SylvainCorlay/comm-unregister

Unregistering comms in Comm Manager
pull/37/head
Min RK 12 years ago
commit d093237f2f

@ -56,9 +56,9 @@ define([
return comm.comm_id;
};
CommManager.prototype.unregister_comm = function (comm_id) {
CommManager.prototype.unregister_comm = function (comm) {
// Remove a comm from the mapping
delete this.comms[comm_id];
delete this.comms[comm.comm_id];
};
// comm message handlers
@ -88,7 +88,7 @@ define([
if (comm === undefined) {
return;
}
delete this.comms[content.comm_id];
this.unregister_comm(comm);
try {
comm.handle_close(msg);
} catch (e) {

@ -141,7 +141,6 @@ class Widget(LoggingConfigurable):
# Create a comm.
self._comm = Comm(target_name=self._model_name)
self._comm.on_msg(self._handle_msg)
self._comm.on_close(self._close)
Widget.widgets[self.model_id] = self
# first update
@ -158,21 +157,18 @@ class Widget(LoggingConfigurable):
#-------------------------------------------------------------------------
# Methods
#-------------------------------------------------------------------------
def _close(self):
"""Private close - cleanup objects, registry entries"""
del Widget.widgets[self.model_id]
self._comm = None
def close(self):
"""Close method.
Closes the widget which closes the underlying comm.
Closes the underlying comm.
When the comm is closed, all of the widget views are automatically
removed from the front-end."""
del Widget.widgets[self.model_id]
if self._comm is not None:
self._comm.close()
self._close()
self._comm = None
def send_state(self, key=None):
"""Sends the widget state, or a piece of it, to the front-end.

Loading…
Cancel
Save