mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-01-31 10:11:17 +00:00
Don't break prematurely when running a cell on an ipython kernel
The kernel may go idle before it processes the next input, which break the while=True loop in run_cell() early. Wait for an acknowledgement of the input we've sent to the kernel before considering an idle message to mean that the cell has been parsed.
This commit is contained in:
parent
0faa5ae455
commit
2b04cb38d9
@ -52,6 +52,7 @@ def run_cell(kernel_client, cell):
|
||||
"""Run a cell of a notebook in an ipython kernel and return its output"""
|
||||
kernel_client.execute(cell.input)
|
||||
|
||||
input_acknowledged = False
|
||||
outs = []
|
||||
while True:
|
||||
msg = kernel_client.get_iopub_msg()
|
||||
@ -61,11 +62,12 @@ def run_cell(kernel_client, cell):
|
||||
out = NotebookNode(output_type=msg_type)
|
||||
|
||||
if msg_type == "status":
|
||||
if content["execution_state"] == "idle":
|
||||
if content["execution_state"] == "idle" and input_acknowledged:
|
||||
break
|
||||
else:
|
||||
continue
|
||||
elif msg_type == "pyin":
|
||||
input_acknowledged = True
|
||||
continue
|
||||
elif msg_type == "stream":
|
||||
out.stream = content["name"]
|
||||
|
Loading…
x
Reference in New Issue
Block a user