Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jupyter/jupyter_client
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v7.4.8
Choose a base ref
...
head repository: jupyter/jupyter_client
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 2ee33ce6b19b34cde3956280f7c6b05da27f8db4
Choose a head ref
  • 2 commits
  • 4 files changed
  • 3 contributors

Commits on Jan 12, 2023

  1. [7.x] Remove deprecated zmq imports (#916)

    * remove deprecated imports
    
    * ignore dep warning in 7.x
    
    * fix typing
    
    * dep warning
    blink1073 authored Jan 12, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    1f8bed3 View commit details
  2. Make Qtconsole work with PyZMQ 25 (#914)

    Co-authored-by: Steven Silvester <steven.silvester@ieee.org>
    Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
    3 people authored Jan 12, 2023
    Copy the full SHA
    2ee33ce View commit details
Showing with 20 additions and 14 deletions.
  1. +1 −1 jupyter_client/ioloop/restarter.py
  2. +1 −1 jupyter_client/session.py
  3. +15 −11 jupyter_client/threaded.py
  4. +3 −1 pyproject.toml
2 changes: 1 addition & 1 deletion jupyter_client/ioloop/restarter.py
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ def _loop_default(self):
DeprecationWarning,
stacklevel=4,
)
from zmq.eventloop import ioloop
from tornado import ioloop

return ioloop.IOLoop.current()

2 changes: 1 addition & 1 deletion jupyter_client/session.py
Original file line number Diff line number Diff line change
@@ -30,6 +30,7 @@
from typing import Union

import zmq.asyncio
from tornado.ioloop import IOLoop
from traitlets import Any
from traitlets import Bool
from traitlets import CBytes
@@ -46,7 +47,6 @@
from traitlets.config.configurable import LoggingConfigurable
from traitlets.log import get_logger
from traitlets.utils.importstring import import_item
from zmq.eventloop.ioloop import IOLoop
from zmq.eventloop.zmqstream import ZMQStream

from jupyter_client import protocol_version
26 changes: 15 additions & 11 deletions jupyter_client/threaded.py
Original file line number Diff line number Diff line change
@@ -16,10 +16,10 @@

import nest_asyncio # type:ignore
import zmq
from tornado.ioloop import IOLoop
from traitlets import Instance
from traitlets import Type
from zmq import ZMQError
from zmq.eventloop import ioloop
from zmq.eventloop import zmqstream

from .session import Session
@@ -48,7 +48,7 @@ def __init__(
self,
socket: Optional[zmq.Socket],
session: Optional[Session],
loop: Optional[zmq.eventloop.ioloop.ZMQIOLoop],
loop: Optional[IOLoop],
) -> None:
"""Create a channel.
@@ -71,7 +71,7 @@ def __init__(
def setup_stream():
assert self.socket is not None
self.stream = zmqstream.ZMQStream(self.socket, self.ioloop)
self.stream.on_recv(self._handle_recv) # type:ignore[arg-type]
self.stream.on_recv(self._handle_recv)
evt.set()

assert self.ioloop is not None
@@ -115,20 +115,24 @@ def thread_send():
assert self.ioloop is not None
self.ioloop.add_callback(thread_send)

def _handle_recv(self, future_msg: Awaitable) -> None:
def _handle_recv(self, msg: Union[List[bytes], Awaitable]) -> None:
"""Callback for stream.on_recv.
Unpacks message, and calls handlers with it.
"""
assert self.ioloop is not None
msg_list = self.ioloop._asyncio_event_loop.run_until_complete(get_msg(future_msg))
if asyncio.isfuture(msg):
assert self.ioloop is not None
loop = self.ioloop._asyncio_event_loop # type:ignore[attr-defined]
msg_list = loop.run_until_complete(get_msg(msg))
else:
msg_list = msg
assert self.session is not None
ident, smsg = self.session.feed_identities(msg_list)
msg = self.session.deserialize(smsg)
new_msg = self.session.deserialize(smsg)
# let client inspect messages
if self._inspect:
self._inspect(msg)
self.call_handlers(msg)
self._inspect(new_msg)
self.call_handlers(new_msg)

def call_handlers(self, msg: Dict[str, Any]) -> None:
"""This method is called in the ioloop thread when a message arrives.
@@ -213,8 +217,8 @@ def run(self) -> None:
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
nest_asyncio.apply(loop)
self.ioloop = ioloop.IOLoop()
self.ioloop._asyncio_event_loop = loop
self.ioloop = IOLoop()
self.ioloop._asyncio_event_loop = loop # type:ignore[attr-defined]
# signal that self.ioloop is defined
self._start_event.set()
while True:
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -128,7 +128,7 @@ filterwarnings= [

# Workaround for https://github.com/tornadoweb/tornado/issues/3106
# (To be fixed in Tornado 6.2)
"ignore:There is no current event loop:DeprecationWarning:tornado",
"ignore:There is no current event loop:DeprecationWarning",

# ZMQ uses Future internally, which raises a DeprecationWarning
# When there is no loop running.
@@ -138,6 +138,8 @@ filterwarnings= [

# Workaround for jupyter_core warning.
"module:Jupyter is migrating its paths to use standard platformdirs:DeprecationWarning",

"ignore:zmq.tests.BaseZMQTestCase is deprecated in pyzmq 25:DeprecationWarning",
]

[tool.mypy]