forked from pool/python-jupyter-client
95 lines
3.9 KiB
Diff
95 lines
3.9 KiB
Diff
|
From 3b854859f91f13d7625ecc9d515bdd3db5641f59 Mon Sep 17 00:00:00 2001
|
||
|
From: Kevin Bates <kbates4@gmail.com>
|
||
|
Date: Tue, 27 Apr 2021 13:32:19 -0700
|
||
|
Subject: [PATCH] Update test kernel to use native coroutine, remove
|
||
|
async_generator dependency
|
||
|
|
||
|
---
|
||
|
jupyter_client/tests/signalkernel.py | 6 ++----
|
||
|
jupyter_client/tests/test_kernelmanager.py | 12 +++++++-----
|
||
|
setup.py | 1 -
|
||
|
3 files changed, 9 insertions(+), 10 deletions(-)
|
||
|
|
||
|
Index: jupyter_client-6.1.12/jupyter_client/tests/signalkernel.py
|
||
|
===================================================================
|
||
|
--- jupyter_client-6.1.12.orig/jupyter_client/tests/signalkernel.py
|
||
|
+++ jupyter_client-6.1.12/jupyter_client/tests/signalkernel.py
|
||
|
@@ -13,8 +13,6 @@ from ipykernel.displayhook import ZMQDis
|
||
|
from ipykernel.kernelbase import Kernel
|
||
|
from ipykernel.kernelapp import IPKernelApp
|
||
|
|
||
|
-from tornado.web import gen
|
||
|
-
|
||
|
import signal
|
||
|
|
||
|
|
||
|
@@ -32,10 +30,9 @@ class SignalTestKernel(Kernel):
|
||
|
if os.environ.get("NO_SIGTERM_REPLY", None) == "1":
|
||
|
signal.signal(signal.SIGTERM, signal.SIG_IGN)
|
||
|
|
||
|
- @gen.coroutine
|
||
|
- def shutdown_request(self, stream, ident, parent):
|
||
|
+ async def shutdown_request(self, stream, ident, parent):
|
||
|
if os.environ.get("NO_SHUTDOWN_REPLY") != "1":
|
||
|
- yield gen.maybe_future(super().shutdown_request(stream, ident, parent))
|
||
|
+ await super().shutdown_request(stream, ident, parent)
|
||
|
|
||
|
def do_execute(self, code, silent, store_history=True, user_expressions=None,
|
||
|
allow_stdin=False):
|
||
|
Index: jupyter_client-6.1.12/jupyter_client/tests/test_kernelmanager.py
|
||
|
===================================================================
|
||
|
--- jupyter_client-6.1.12.orig/jupyter_client/tests/test_kernelmanager.py
|
||
|
+++ jupyter_client-6.1.12/jupyter_client/tests/test_kernelmanager.py
|
||
|
@@ -14,7 +14,6 @@ import threading
|
||
|
import multiprocessing as mp
|
||
|
import pytest
|
||
|
|
||
|
-from async_generator import async_generator, yield_
|
||
|
from traitlets.config.loader import Config
|
||
|
from jupyter_core import paths
|
||
|
from jupyter_client import KernelManager, AsyncKernelManager
|
||
|
@@ -131,10 +130,9 @@ def async_km_subclass(config):
|
||
|
|
||
|
|
||
|
@pytest.fixture
|
||
|
-@async_generator # This is only necessary while Python 3.5 is support afterwhich both it and yield_() can be removed
|
||
|
async def start_async_kernel():
|
||
|
km, kc = await start_new_async_kernel(kernel_name='signaltest')
|
||
|
- await yield_((km, kc))
|
||
|
+ yield km, kc
|
||
|
kc.stop_channels()
|
||
|
await km.shutdown_kernel()
|
||
|
assert km.context.closed
|
||
|
@@ -163,6 +161,9 @@ class TestKernelManagerShutDownGracefull
|
||
|
)
|
||
|
@pytest.mark.parametrize(*parameters)
|
||
|
def test_signal_kernel_subprocesses(self, name, install, expected):
|
||
|
+ # ipykernel doesn't support 3.6 and this test uses async shutdown_request; broken on obs
|
||
|
+ if expected == _ShutdownStatus.ShutdownRequest:
|
||
|
+ pytest.skip()
|
||
|
install()
|
||
|
km, kc = start_new_kernel(kernel_name=name)
|
||
|
assert km._shutdown_status == _ShutdownStatus.Unset
|
||
|
@@ -178,6 +179,9 @@ class TestKernelManagerShutDownGracefull
|
||
|
)
|
||
|
@pytest.mark.parametrize(*parameters)
|
||
|
async def test_async_signal_kernel_subprocesses(self, name, install, expected):
|
||
|
+ # ipykernel doesn't support 3.6 and this test uses async shutdown_request
|
||
|
+ if expected == _ShutdownStatus.ShutdownRequest and sys.version_info < (3, 7):
|
||
|
+ pytest.skip()
|
||
|
install()
|
||
|
km, kc = await start_new_async_kernel(kernel_name=name)
|
||
|
assert km._shutdown_status == _ShutdownStatus.Unset
|
||
|
Index: jupyter_client-6.1.12/setup.py
|
||
|
===================================================================
|
||
|
--- jupyter_client-6.1.12.orig/setup.py
|
||
|
+++ jupyter_client-6.1.12/setup.py
|
||
|
@@ -78,7 +78,6 @@ setup_args = dict(
|
||
|
python_requires = '>=3.5',
|
||
|
extras_require = {
|
||
|
'test': [
|
||
|
- 'async_generator',
|
||
|
'ipykernel',
|
||
|
'ipython',
|
||
|
'jedi<0.18; python_version<="3.6"',
|