@@ -274,10 +274,9 @@ async def process_control_message(self, msg=None):
274274 assert self .control_thread is None or threading .current_thread () == self .control_thread
275275
276276 msg = msg or await self .control_socket .recv_multipart ()
277- copy = not isinstance (msg [0 ], zmq .Message )
278- idents , msg = self .session .feed_identities (msg , copy = copy )
277+ idents , msg = self .session .feed_identities (msg )
279278 try :
280- msg = self .session .deserialize (msg , content = True , copy = copy )
279+ msg = self .session .deserialize (msg , content = True )
281280 except Exception :
282281 self .log .error ("Invalid Control Message" , exc_info = True ) # noqa: G201
283282 return
@@ -375,15 +374,12 @@ async def shell_channel_thread_main(self):
375374
376375 try :
377376 while True :
378- msg = await self .shell_socket .recv_multipart ()
379-
380- # Deserialize whole message just to get subshell_id.
377+ msg = await self .shell_socket .recv_multipart (copy = False )
378+ # deserialize only the header to get subshell_id
381379 # Keep original message to send to subshell_id unmodified.
382- # Ideally only want to deserialize message once.
383- copy = not isinstance (msg [0 ], zmq .Message )
384- _ , msg2 = self .session .feed_identities (msg , copy = copy )
380+ _ , msg2 = self .session .feed_identities (msg , copy = False )
385381 try :
386- msg3 = self .session .deserialize (msg2 , content = False , copy = copy )
382+ msg3 = self .session .deserialize (msg2 , content = False , copy = False )
387383 subshell_id = msg3 ["header" ].get ("subshell_id" )
388384
389385 # Find inproc pair socket to use to send message to correct subshell.
@@ -1210,9 +1206,7 @@ def do_clear(self):
12101206
12111207 def _topic (self , topic ):
12121208 """prefixed topic for IOPub messages"""
1213- base = "kernel.%s" % self .ident
1214-
1215- return (f"{ base } .{ topic } " ).encode ()
1209+ return (f"kernel.{ self .ident } .{ topic } " ).encode ()
12161210
12171211 _aborting = Bool (False )
12181212
0 commit comments