diff --git a/ipykernel/ipkernel.py b/ipykernel/ipkernel.py index db83d986..9d201e32 100644 --- a/ipykernel/ipkernel.py +++ b/ipykernel/ipkernel.py @@ -411,6 +411,7 @@ async def run(execution: Execution) -> None: try: async with create_task_group() as tg: execution = Execution() + self.shell_is_blocking = False self.shell_is_awaiting = True tg.start_soon(run, execution) execution.interrupt = await to_thread.run_sync(self.shell_interrupt.get) diff --git a/ipykernel/kernelbase.py b/ipykernel/kernelbase.py index 64a93527..bb8535b0 100644 --- a/ipykernel/kernelbase.py +++ b/ipykernel/kernelbase.py @@ -659,7 +659,9 @@ async def execute_request(self, socket, ident, parent): do_execute_args["cell_id"] = cell_id # Call do_execute with the appropriate arguments + self.shell_is_blocking = True reply_content = self.do_execute(**do_execute_args) + self.shell_is_blocking = False if inspect.isawaitable(reply_content): reply_content = await reply_content