@@ -472,19 +472,19 @@ async def shell_main(self, subshell_id: str | None):
472472 async def _execute_request_loop (self , receive_stream : MemoryObjectReceiveStream ):
473473 async with receive_stream :
474474 async for handler , (received_time , socket , idents , msg ) in receive_stream :
475+ self .set_parent (idents , msg , channel = "shell" )
476+ self ._publish_status ("busy" , "shell" , parent = msg )
475477 try :
476478 if received_time < self ._aborted_time :
477479 await self ._send_abort_reply (socket , msg , idents )
478480 continue
479- self .set_parent (idents , msg , channel = "shell" )
480- self ._publish_status ("busy" , "shell" , parent = msg )
481481 result = handler (socket , idents , msg )
482482 if inspect .isawaitable (result ):
483483 await result
484- self .set_parent (idents , msg , channel = "shell" )
485- self ._publish_status ("idle" , "shell" , parent = msg )
486484 except BaseException as e :
487485 self .log .exception ("Execute request" , exc_info = e )
486+ finally :
487+ self ._publish_status ("idle" , "shell" , parent = msg )
488488
489489 async def _process_shell (self , socket ):
490490 # socket=None is valid if kernel subshells are not supported.
0 commit comments