|
11 | 11 | from unittest import TestCase |
12 | 12 |
|
13 | 13 | import pytest |
| 14 | +import zmq |
14 | 15 | from jupyter_core import paths |
15 | 16 | from tornado.testing import AsyncTestCase, gen_test |
16 | 17 | from traitlets.config.loader import Config |
@@ -43,6 +44,11 @@ async def now(awaitable): |
43 | 44 |
|
44 | 45 | class TestKernelManager(TestCase): |
45 | 46 | # static so picklable for multiprocessing on Windows |
| 47 | + |
| 48 | + def tearDown(self): |
| 49 | + zmq.Context.instance().destroy(linger=0) |
| 50 | + return super().tearDown() |
| 51 | + |
46 | 52 | @staticmethod |
47 | 53 | def _get_tcp_km(): |
48 | 54 | c = Config() |
@@ -265,13 +271,16 @@ def record_activity(msg_list): |
265 | 271 | time.sleep(0.1) |
266 | 272 | if called: |
267 | 273 | break |
268 | | - |
| 274 | + stream.close() |
269 | 275 | client.stop_channels() |
270 | 276 | km.shutdown_kernel(now=True) |
271 | 277 |
|
272 | 278 |
|
273 | | -@pytest.mark.skipif(sys.version_info < (3, 10), reason="issue on 3.9") |
274 | 279 | class TestAsyncKernelManager(AsyncTestCase): |
| 280 | + def tearDown(self): |
| 281 | + zmq.Context.instance().destroy(linger=0) |
| 282 | + return super().tearDown() |
| 283 | + |
275 | 284 | # static so picklable for multiprocessing on Windows |
276 | 285 | @staticmethod |
277 | 286 | def _get_tcp_km(): |
@@ -616,7 +625,7 @@ async def test_bad_kernelspec_pending(self): |
616 | 625 | await ensure_future(km.shutdown_kernel(kernel_id)) |
617 | 626 | assert kernel_id not in km.list_kernel_ids() |
618 | 627 |
|
619 | | - @gen_test |
| 628 | + @gen_test(timeout=10) |
620 | 629 | async def test_stream_on_recv(self): |
621 | 630 | mkm = self._get_tcp_km() |
622 | 631 | kid = await mkm.start_kernel(stdout=PIPE, stderr=PIPE) |
@@ -645,4 +654,5 @@ def record_activity(msg_list): |
645 | 654 | await asyncio.sleep(0.1) |
646 | 655 |
|
647 | 656 | client.stop_channels() |
| 657 | + stream.close() |
648 | 658 | await km.shutdown_kernel(now=True) |
0 commit comments