Skip to content

Commit d6033cd

Browse files
committed
fix: add flag to allow to stop to avoid stopping too early after restart kernel and run all cells
1 parent eb96748 commit d6033cd

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

jupyter_client/client.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,7 @@ async def _async_execute_interactive(
540540
stdin_socket = None
541541

542542
# wait for output and redisplay it
543+
can_stop = False
543544
while True:
544545
if timeout is not None:
545546
timeout = max(0, deadline - time.monotonic())
@@ -564,12 +565,14 @@ async def _async_execute_interactive(
564565
continue
565566
output_hook(msg)
566567

567-
# stop on idle
568-
if (
569-
msg["header"]["msg_type"] == "status"
570-
and msg["content"]["execution_state"] == "idle"
571-
):
572-
break
568+
state = msg["content"]["execution_state"]
569+
if msg["header"]["msg_type"] == "status":
570+
# allow to stop
571+
if state == 'busy':
572+
can_stop = True
573+
# stop on idle
574+
if state == 'idle' and can_stop:
575+
break
573576

574577
# output is done, get the reply
575578
if timeout is not None:

0 commit comments

Comments
 (0)