From 6607d5219f99b7e9c743186a79eb071b9ee9eb76 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 11 Oct 2022 16:07:01 -0500 Subject: [PATCH 1/2] fix ready promise and session send --- jupyter_client/manager.py | 13 ++++++++----- jupyter_client/session.py | 6 +++++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/jupyter_client/manager.py b/jupyter_client/manager.py index 19afd0db7..531435045 100644 --- a/jupyter_client/manager.py +++ b/jupyter_client/manager.py @@ -65,11 +65,12 @@ def in_pending_state(method: F) -> F: @functools.wraps(method) async def wrapper(self, *args, **kwargs): # Create a future for the decorated method - try: - self._ready = Future() - except RuntimeError: - # No event loop running, use concurrent future - self._ready = CFuture() + if self._attempted_start: + try: + self._ready = Future() + except RuntimeError: + # No event loop running, use concurrent future + self._ready = CFuture() try: # call wrapped method, await, and set the result or exception. out = await method(self, *args, **kwargs) @@ -96,6 +97,7 @@ class KernelManager(ConnectionFileMixin): def __init__(self, *args, **kwargs): super().__init__(**kwargs) self._shutdown_status = _ShutdownStatus.Unset + self._attempted_start = False # Create a place holder future. try: asyncio.get_running_loop() @@ -382,6 +384,7 @@ async def _async_start_kernel(self, **kw: t.Any) -> None: keyword arguments that are passed down to build the kernel_cmd and launching the kernel (e.g. Popen kwargs). """ + self._attempted_start = True kernel_cmd, kw = await ensure_async(self.pre_start_kernel(**kw)) # launch the kernel subprocess diff --git a/jupyter_client/session.py b/jupyter_client/session.py index 63753f8a4..d253c1946 100644 --- a/jupyter_client/session.py +++ b/jupyter_client/session.py @@ -29,7 +29,7 @@ from typing import Optional from typing import Union -import zmq +import zmq.asyncio from traitlets import Any from traitlets import Bool from traitlets import CBytes @@ -807,6 +807,10 @@ def send( # ZMQStreams and dummy sockets do not support tracking. track = False + if isinstance(stream, zmq.asyncio.Socket): + assert stream is not None + stream = zmq.Socket.shadow(stream.underlying) + if isinstance(msg_or_type, (Message, dict)): # We got a Message or message dict, not a msg_type so don't # build a new Message. From ac87e6099a99a688058eafa38c0ce048f02f73cd Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Tue, 11 Oct 2022 16:09:04 -0500 Subject: [PATCH 2/2] ignore warnings in prerelease job --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4c3540ec8..157da7506 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -130,7 +130,7 @@ jobs: pip check - name: Run the tests run: | - pytest -vv jupyter_client || pytest -vv jupyter_client --lf + pytest -vv -W default jupyter_client || pytest -vv -W default jupyter_client --lf make_sdist: name: Make SDist