File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -117,10 +117,15 @@ def _context_default(self) -> zmq.asyncio.Context:
117
117
allow_stdin : bool = True
118
118
119
119
def __del__ (self ):
120
+ """Handle garbage collection. Destroy context if applicable."""
120
121
if self ._created_context and self .context and not self .context .closed :
121
- if self .log :
122
- self .log .debug ("Destroying zmq context for %s" , self )
123
- self .context .destroy ()
122
+ if self .channels_running :
123
+ if self .log :
124
+ self .log .warning ("Could not destroy zmq context for %s" , self )
125
+ else :
126
+ if self .log :
127
+ self .log .debug ("Destroying zmq context for %s" , self )
128
+ self .context .destroy ()
124
129
try :
125
130
super_del = super ().__del__
126
131
except AttributeError :
Original file line number Diff line number Diff line change @@ -116,6 +116,7 @@ def _context_default(self) -> zmq.Context:
116
116
_kernels = Dict ()
117
117
118
118
def __del__ (self ):
119
+ """Handle garbage collection. Destroy context if applicable."""
119
120
if self ._created_context and self .context and not self .context .closed :
120
121
if self .log :
121
122
self .log .debug ("Destroying zmq context for %s" , self )
You can’t perform that action at this time.
0 commit comments