@@ -79,6 +79,7 @@ def _accepts_parameters(meth, param_names):
7979
8080class Kernel (SingletonConfigurable ):
8181 """The base kernel class."""
82+
8283 # ---------------------------------------------------------------------------
8384 # Kernel interface
8485 # ---------------------------------------------------------------------------
@@ -276,12 +277,8 @@ def __init__(self, **kwargs):
276277 """Initialize the kernel."""
277278 super ().__init__ (** kwargs )
278279
279-
280-
281280 self ._iant_lock = threading .Lock ()
282281
283-
284-
285282 # Kernel application may swap stdout and stderr to OutStream,
286283 # which is the case in `IPKernelApp.init_io`, hence `sys.stdout`
287284 # can already by different from TextIO at initialization time.
@@ -619,7 +616,9 @@ async def shell_channel_thread_main(self, msg):
619616 subshell_id = msg3 ["header" ].get ("subshell_id" )
620617
621618 with open ("debug.txt" , "a" ) as f :
622- f .write (f"{ threading .current_thread ().ident } shell_channel_thread_main msg received for { subshell_id } \n " )
619+ f .write (
620+ f"{ threading .current_thread ().ident } shell_channel_thread_main msg received for { subshell_id } \n "
621+ )
623622
624623 # Find inproc pair socket to use to send message to correct subshell.
625624 subshell_manager = self .shell_channel_thread .manager
@@ -684,7 +683,6 @@ def _publish_execute_input(self, code, parent, execution_count):
684683 if not self .session :
685684 return
686685 with self ._iant_lock :
687-
688686 with open ("debug.txt" , "a" ) as f :
689687 f .write (f"{ threading .current_thread ().ident } iopub_socket execute_input\n " )
690688
@@ -701,7 +699,6 @@ def _publish_status(self, status, channel, parent=None):
701699 if not self .session :
702700 return
703701 with self ._iant_lock :
704-
705702 with open ("debug.txt" , "a" ) as f :
706703 f .write (f"{ threading .current_thread ().ident } iopub_socket status { status } \n " )
707704
@@ -723,7 +720,6 @@ def _publish_debug_event(self, event):
723720 if not self .session :
724721 return
725722 with self ._iant_lock :
726-
727723 with open ("debug.txt" , "a" ) as f :
728724 f .write (f"{ threading .current_thread ().ident } iopub_socket debug_event\n " )
729725
@@ -870,12 +866,13 @@ async def execute_request(self, stream, ident, parent):
870866 if self ._do_exec_accepted_params ["cell_id" ]:
871867 do_execute_args ["cell_id" ] = cell_id
872868
873-
874869 subshell_id = parent ["header" ].get ("subshell_id" )
875870 msg_id = parent ["header" ].get ("msg_id" )
876871
877872 with open ("debug.txt" , "a" ) as f :
878- f .write (f"{ threading .current_thread ().ident } about to execute_request { msg_id } { subshell_id } { code } \n " )
873+ f .write (
874+ f"{ threading .current_thread ().ident } about to execute_request { msg_id } { subshell_id } { code } \n "
875+ )
879876
880877 # Call do_execute with the appropriate arguments
881878 reply_content = self .do_execute (** do_execute_args )
@@ -897,7 +894,9 @@ async def execute_request(self, stream, ident, parent):
897894 metadata = self .finish_metadata (parent , metadata , reply_content )
898895
899896 with open ("debug.txt" , "a" ) as f :
900- f .write (f"{ threading .current_thread ().ident } execute_reply { msg_id } { subshell_id } \n " )
897+ f .write (
898+ f"{ threading .current_thread ().ident } execute_reply { msg_id } { subshell_id } \n "
899+ )
901900
902901 reply_msg : dict [str , t .Any ] = self .session .send ( # type:ignore[assignment]
903902 stream ,
@@ -1643,7 +1642,6 @@ async def _at_shutdown(self):
16431642 finally :
16441643 if self ._shutdown_message is not None and self .session :
16451644 with self ._iant_lock :
1646-
16471645 with open ("debug.txt" , "a" ) as f :
16481646 f .write (f"{ threading .current_thread ().ident } ? _shutdown\n " )
16491647
0 commit comments