Skip to content

Commit 6423252

Browse files
committed
Allow reentrant SocketPair
1 parent 2564a2b commit 6423252

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

ipykernel/socket_pair.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class SocketPair:
1616

1717
from_socket: zmq.Socket[Any]
1818
to_socket: zmq.Socket[Any]
19-
to_stream: ZMQStream
19+
to_stream: ZMQStream | None = None
2020
on_recv_callback: Any
2121
on_recv_copy: bool
2222

@@ -38,7 +38,8 @@ def on_recv(self, io_loop: IOLoop, on_recv_callback, copy: bool = False):
3838
# io_loop is that of the 'to' thread.
3939
self.on_recv_callback = on_recv_callback
4040
self.on_recv_copy = copy
41-
self.to_stream = ZMQStream(self.to_socket, io_loop)
41+
if self.to_stream is None:
42+
self.to_stream = ZMQStream(self.to_socket, io_loop)
4243
self.resume_on_recv()
4344

4445
def pause_on_recv(self):

0 commit comments

Comments
 (0)