@@ -277,7 +277,7 @@ def __init__(self, **kwargs):
277277 """Initialize the kernel."""
278278 super ().__init__ (** kwargs )
279279
280- self ._iant_lock = threading .Lock ()
280+ # self._iant_lock = threading.Lock()
281281
282282 # Kernel application may swap stdout and stderr to OutStream,
283283 # which is the case in `IPKernelApp.init_io`, hence `sys.stdout`
@@ -682,33 +682,33 @@ def _publish_execute_input(self, code, parent, execution_count):
682682 """Publish the code request on the iopub stream."""
683683 if not self .session :
684684 return
685- with self ._iant_lock :
686- with open ("debug.txt" , "a" ) as f :
687- f .write (f"{ threading .current_thread ().ident } iopub_socket execute_input\n " )
688-
689- self .session .send (
690- self .iopub_socket ,
691- "execute_input" ,
692- {"code" : code , "execution_count" : execution_count },
693- parent = parent ,
694- ident = self ._topic ("execute_input" ),
695- )
685+ # with self._iant_lock:
686+ with open ("debug.txt" , "a" ) as f :
687+ f .write (f"{ threading .current_thread ().ident } iopub_socket execute_input\n " )
688+
689+ self .session .send (
690+ self .iopub_socket ,
691+ "execute_input" ,
692+ {"code" : code , "execution_count" : execution_count },
693+ parent = parent ,
694+ ident = self ._topic ("execute_input" ),
695+ )
696696
697697 def _publish_status (self , status , channel , parent = None ):
698698 """send status (busy/idle) on IOPub"""
699699 if not self .session :
700700 return
701- with self ._iant_lock :
702- with open ("debug.txt" , "a" ) as f :
703- f .write (f"{ threading .current_thread ().ident } iopub_socket status { status } \n " )
704-
705- self .session .send (
706- self .iopub_socket ,
707- "status" ,
708- {"execution_state" : status },
709- parent = parent or self .get_parent (channel ),
710- ident = self ._topic ("status" ),
711- )
701+ # with self._iant_lock:
702+ with open ("debug.txt" , "a" ) as f :
703+ f .write (f"{ threading .current_thread ().ident } iopub_socket status { status } \n " )
704+
705+ self .session .send (
706+ self .iopub_socket ,
707+ "status" ,
708+ {"execution_state" : status },
709+ parent = parent or self .get_parent (channel ),
710+ ident = self ._topic ("status" ),
711+ )
712712
713713 def _publish_status_and_flush (self , status , channel , stream , parent = None ):
714714 """send status on IOPub and flush specified stream to ensure reply is sent before handling the next reply"""
@@ -719,17 +719,17 @@ def _publish_status_and_flush(self, status, channel, stream, parent=None):
719719 def _publish_debug_event (self , event ):
720720 if not self .session :
721721 return
722- with self ._iant_lock :
723- with open ("debug.txt" , "a" ) as f :
724- f .write (f"{ threading .current_thread ().ident } iopub_socket debug_event\n " )
725-
726- self .session .send (
727- self .iopub_socket ,
728- "debug_event" ,
729- event ,
730- parent = self .get_parent (),
731- ident = self ._topic ("debug_event" ),
732- )
722+ # with self._iant_lock:
723+ with open ("debug.txt" , "a" ) as f :
724+ f .write (f"{ threading .current_thread ().ident } iopub_socket debug_event\n " )
725+
726+ self .session .send (
727+ self .iopub_socket ,
728+ "debug_event" ,
729+ event ,
730+ parent = self .get_parent (),
731+ ident = self ._topic ("debug_event" ),
732+ )
733733
734734 def set_parent (self , ident , parent , channel = "shell" ):
735735 """Set the current parent request
@@ -895,7 +895,7 @@ async def execute_request(self, stream, ident, parent):
895895
896896 with open ("debug.txt" , "a" ) as f :
897897 f .write (
898- f"{ threading .current_thread ().ident } execute_reply { msg_id } { subshell_id } \n "
898+ f"{ threading .current_thread ().ident } execute_reply { msg_id } { subshell_id } { reply_content } \n "
899899 )
900900
901901 reply_msg : dict [str , t .Any ] = self .session .send ( # type:ignore[assignment]
@@ -1234,6 +1234,11 @@ async def create_subshell_request(self, socket, ident, parent) -> None:
12341234 self .log .error ("Subshells are not supported by this kernel" )
12351235 return
12361236
1237+
1238+ with open ("debug.txt" , "a" ) as f :
1239+ f .write (f"{ threading .current_thread ().ident } ? create_subshell_request\n " )
1240+
1241+
12371242 assert threading .current_thread ().name == CONTROL_THREAD_NAME
12381243
12391244 # This should only be called in the control thread if it exists.
@@ -1641,15 +1646,15 @@ async def _at_shutdown(self):
16411646
16421647 finally :
16431648 if self ._shutdown_message is not None and self .session :
1644- with self ._iant_lock :
1645- with open ("debug.txt" , "a" ) as f :
1646- f .write (f"{ threading .current_thread ().ident } ? _shutdown\n " )
1647-
1648- self .session .send (
1649- self .iopub_socket ,
1650- self ._shutdown_message ,
1651- ident = self ._topic ("shutdown" ),
1652- )
1649+ # with self._iant_lock:
1650+ with open ("debug.txt" , "a" ) as f :
1651+ f .write (f"{ threading .current_thread ().ident } ? _shutdown\n " )
1652+
1653+ self .session .send (
1654+ self .iopub_socket ,
1655+ self ._shutdown_message ,
1656+ ident = self ._topic ("shutdown" ),
1657+ )
16531658 self .log .debug ("%s" , self ._shutdown_message )
16541659 if self .control_stream :
16551660 self .control_stream .flush (zmq .POLLOUT )
0 commit comments