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

Make Qtconsole work with PyZMQ 25 #914

Merged
merged 4 commits into from
Jan 12, 2023
Merged
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
19 changes: 11 additions & 8 deletions jupyter_client/threaded.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -115,21 +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
loop = self.ioloop._asyncio_event_loop # type:ignore[attr-defined]
msg_list = 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.
Expand Down