Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update test kernel with native coroutine, remove async_generator dependency #646

Merged
merged 1 commit into from
Apr 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions jupyter_client/tests/signalkernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from ipykernel.displayhook import ZMQDisplayHook
from ipykernel.kernelapp import IPKernelApp
from ipykernel.kernelbase import Kernel
from tornado.web import gen


class SignalTestKernel(Kernel):
Expand All @@ -28,10 +27,9 @@ def __init__(self, **kwargs):
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
Expand Down
12 changes: 7 additions & 5 deletions jupyter_client/tests/test_kernelmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
from subprocess import PIPE

import pytest
from async_generator import async_generator
from async_generator import yield_
from jupyter_core import paths
from traitlets.config.loader import Config

Expand Down Expand Up @@ -135,11 +133,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
Expand All @@ -166,6 +162,9 @@ class TestKernelManagerShutDownGracefully:
@pytest.mark.skipif(sys.platform == "win32", reason="Windows doesn't support signals")
@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
if expected == _ShutdownStatus.ShutdownRequest and sys.version_info < (3, 7):
pytest.skip()
install()
km, kc = start_new_kernel(kernel_name=name)
assert km._shutdown_status == _ShutdownStatus.Unset
Expand All @@ -180,6 +179,9 @@ def test_signal_kernel_subprocesses(self, name, install, expected):
@pytest.mark.skipif(sys.platform == "win32", reason="Windows doesn't support signals")
@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
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ def run(self):
python_requires='>=3.6.1',
extras_require={
'test': [
'async_generator',
'ipykernel',
'ipython',
'jedi<0.18; python_version<="3.6"',
Expand Down