@@ -69,6 +69,7 @@ def _run_lifecycle(km, test_kid=None):
69
69
assert isinstance (k , KernelManager )
70
70
km .shutdown_kernel (kid , now = True )
71
71
assert kid not in km , f"{ kid } not in { km } "
72
+ km .context .term ()
72
73
73
74
def _run_cinfo (self , km , transport , ip ):
74
75
kid = km .start_kernel (stdout = PIPE , stderr = PIPE )
@@ -87,6 +88,7 @@ def _run_cinfo(self, km, transport, ip):
87
88
stream = km .connect_hb (kid )
88
89
stream .close ()
89
90
km .shutdown_kernel (kid , now = True )
91
+ km .context .term ()
90
92
91
93
# static so picklable for multiprocessing on Windows
92
94
@classmethod
@@ -106,6 +108,7 @@ def test_shutdown_all(self):
106
108
self .assertNotIn (kid , km )
107
109
# shutdown again is okay, because we have no kernels
108
110
km .shutdown_all ()
111
+ km .context .term ()
109
112
110
113
def test_tcp_cinfo (self ):
111
114
km = self ._get_tcp_km ()
@@ -217,6 +220,7 @@ def test_subclass_callables(self):
217
220
assert km .call_count ("cleanup_resources" ) == 0
218
221
219
222
assert kid not in km , f"{ kid } not in { km } "
223
+ km .context .term ()
220
224
221
225
222
226
class TestAsyncKernelManager (AsyncTestCase ):
@@ -263,6 +267,7 @@ async def _run_lifecycle(km, test_kid=None):
263
267
assert isinstance (k , AsyncKernelManager )
264
268
await km .shutdown_kernel (kid , now = True )
265
269
assert kid not in km , f"{ kid } not in { km } "
270
+ km .context .term ()
266
271
267
272
async def _run_cinfo (self , km , transport , ip ):
268
273
kid = await km .start_kernel (stdout = PIPE , stderr = PIPE )
@@ -282,6 +287,7 @@ async def _run_cinfo(self, km, transport, ip):
282
287
stream .close ()
283
288
await km .shutdown_kernel (kid , now = True )
284
289
self .assertNotIn (kid , km )
290
+ km .context .term ()
285
291
286
292
@gen_test
287
293
async def test_tcp_lifecycle (self ):
@@ -316,6 +322,7 @@ async def test_use_after_shutdown_all(self):
316
322
self .assertNotIn (kid , km )
317
323
# shutdown again is okay, because we have no kernels
318
324
await km .shutdown_all ()
325
+ km .context .term ()
319
326
320
327
@gen_test (timeout = 20 )
321
328
async def test_shutdown_all_while_starting (self ):
@@ -333,6 +340,7 @@ async def test_shutdown_all_while_starting(self):
333
340
self .assertNotIn (kid , km )
334
341
# shutdown again is okay, because we have no kernels
335
342
await km .shutdown_all ()
343
+ km .context .term ()
336
344
337
345
@gen_test
338
346
async def test_tcp_cinfo (self ):
@@ -466,3 +474,4 @@ async def test_subclass_callables(self):
466
474
assert mkm .call_count ("cleanup_resources" ) == 0
467
475
468
476
assert kid not in mkm , f"{ kid } not in { mkm } "
477
+ mkm .context .term ()
0 commit comments