File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -116,6 +116,10 @@ def _context_default(self) -> zmq.asyncio.Context:
116
116
# flag for whether execute requests should be allowed to call raw_input:
117
117
allow_stdin : bool = True
118
118
119
+ def __del__ (self ):
120
+ """Destroy our context when we are garbage collected."""
121
+ self .context .destroy ()
122
+
119
123
# --------------------------------------------------------------------------
120
124
# Channel proxy methods
121
125
# --------------------------------------------------------------------------
@@ -320,7 +324,6 @@ def stop_channels(self) -> None:
320
324
self .control_channel .stop ()
321
325
if self ._created_context :
322
326
self ._created_context = False
323
- self .context .destroy ()
324
327
325
328
@property
326
329
def channels_running (self ) -> bool :
Original file line number Diff line number Diff line change @@ -160,8 +160,10 @@ def test_start_sequence_ipc_kernels(self):
160
160
161
161
def tcp_lifecycle_with_loop (self ):
162
162
# Ensure each thread has an event loop
163
- asyncio .set_event_loop (asyncio .new_event_loop ())
163
+ loop = asyncio .new_event_loop ()
164
+ asyncio .set_event_loop (loop )
164
165
self .test_tcp_lifecycle ()
166
+ loop .close ()
165
167
166
168
def test_start_parallel_thread_kernels (self ):
167
169
self .test_tcp_lifecycle ()
You can’t perform that action at this time.
0 commit comments