From 168548ebbcb0880c50cab3d13fca39c3d10b1461 Mon Sep 17 00:00:00 2001 From: Matthias Bussonnier Date: Wed, 1 Sep 2021 13:55:46 -0700 Subject: [PATCH] Stop using deprecated recv_multipart when using in-process socket. Found while working on https://github.com/napari/napari/issues/3314 This should be the right fix, as BackgroundSocket is used only in inprocess kernel, and while in general iopub_socket looks like it can be `Any()` for this particular class we have a trait saying iopub_socket has to be a BackgroundSocket The recv in jupyter_client side (which is called by the line I change here) is def recv(self, socket, mode=zmq.NOBLOCK, content=True, copy=True): """Receive and unpack a message. Parameters ---------- socket : ZMQStream or Socket The socket or stream to use in receiving. Returns ------- [idents], msg [idents] is a list of idents and msg is a nested message dict of same format as self.msg returns. """ if isinstance(socket, ZMQStream): socket = socket.socket try: msg_list = socket.recv_multipart(mode, copy=copy) # this will trigger deprecation warning except zmq.ZMQError as e: ... And I doubt we want to make that aware of background socket. --- ipykernel/inprocess/ipkernel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ipykernel/inprocess/ipkernel.py b/ipykernel/inprocess/ipkernel.py index 0e86c8f6d..9a10117eb 100644 --- a/ipykernel/inprocess/ipkernel.py +++ b/ipykernel/inprocess/ipkernel.py @@ -131,7 +131,7 @@ def _redirected_io(self): def _io_dispatch(self, change): """ Called when a message is sent to the IO socket. """ - ident, msg = self.session.recv(self.iopub_socket, copy=False) + ident, msg = self.session.recv(self.iopub_socket.io_thread.socket, copy=False) for frontend in self.frontends: frontend.iopub_channel.call_handlers(msg)