Skip to content

Commit 0057186

Browse files
committed
Update pyzmq >=23.0
1 parent 692bc30 commit 0057186

File tree

3 files changed

+6
-14
lines changed

3 files changed

+6
-14
lines changed

jupyter_client/channels.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ def _create_socket(self) -> None:
101101
assert self.context is not None
102102
self.socket = self.context.socket(zmq.REQ)
103103
self.socket.linger = 1000
104+
assert self.address is not None
104105
self.socket.connect(self.address)
105106

106107
self.poller.register(self.socket, zmq.POLLIN)
@@ -192,9 +193,7 @@ def call_handlers(self, since_last_heartbeat: float) -> None:
192193
class ZMQSocketChannel(object):
193194
"""A ZMQ socket in an async API"""
194195

195-
def __init__(
196-
self, socket: zmq.sugar.socket.Socket, session: Session, loop: t.Any = None
197-
) -> None:
196+
def __init__(self, socket: zmq.asyncio.Socket, session: Session, loop: t.Any = None) -> None:
198197
"""Create a channel.
199198
200199
Parameters
@@ -208,7 +207,7 @@ def __init__(
208207
"""
209208
super().__init__()
210209

211-
self.socket: t.Optional[zmq.sugar.socket.Socket] = socket
210+
self.socket: t.Optional[zmq.asyncio.Socket] = socket
212211
self.session = session
213212

214213
async def _recv(self, **kwargs: t.Any) -> t.Dict[str, t.Any]:

jupyter_client/threaded.py

+2-9
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@
88
from threading import Event
99
from threading import Thread
1010
from typing import Any
11-
from typing import Awaitable
1211
from typing import Dict
1312
from typing import List
1413
from typing import Optional
15-
from typing import Union
1614

1715
import zmq
1816
from traitlets import Instance
@@ -30,10 +28,6 @@
3028
# during garbage collection of threads at exit
3129

3230

33-
async def get_msg(msg: Awaitable) -> Union[List[bytes], List[zmq.Message]]:
34-
return await msg
35-
36-
3731
class ThreadedZMQSocketChannel(object):
3832
"""A ZMQ socket invoking a callback in the ioloop"""
3933

@@ -68,6 +62,7 @@ def __init__(
6862
evt = Event()
6963

7064
def setup_stream():
65+
assert self.socket is not None
7166
self.stream = zmqstream.ZMQStream(self.socket, self.ioloop)
7267
self.stream.on_recv(self._handle_recv)
7368
evt.set()
@@ -113,13 +108,11 @@ def thread_send():
113108
assert self.ioloop is not None
114109
self.ioloop.add_callback(thread_send)
115110

116-
def _handle_recv(self, future_msg: Awaitable) -> None:
111+
def _handle_recv(self, msg_list: List[bytes]) -> None:
117112
"""Callback for stream.on_recv.
118113
119114
Unpacks message, and calls handlers with it.
120115
"""
121-
assert self.ioloop is not None
122-
msg_list = self.ioloop._asyncio_event_loop.run_until_complete(get_msg(future_msg))
123116
assert self.session is not None
124117
ident, smsg = self.session.feed_identities(msg_list)
125118
msg = self.session.deserialize(smsg)

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ dependencies = [
2828
"jupyter_core>=4.9.2",
2929
"nest-asyncio>=1.5.4",
3030
"python-dateutil>=2.8.2",
31-
"pyzmq>=22.3",
31+
"pyzmq>=23.0",
3232
"tornado>=6.0",
3333
"traitlets",
3434
]

0 commit comments

Comments
 (0)