jupyter/qtconsole

Values missing from console when running automatically

keziah55 opened this issue · 0 comments

I'm trying to automatically run a sequence of commands in the QtConsole. I'm doing this by listening for 'execute_reply' messages from the kernel_client.shell_channel and using these to trigger the next command. However, some of the commands are missing from the console.

I've created a minimal working example from the embed_qtconsole.py example:
embed_qtconsole.py.txt
To demonstrate the problem, click 'Connect signal', 'then 'Run'.

Sample output:

In [1]: i = 1

In [2]: i = 2


In [3]: i = 4

In [4]: i = 5

In [5]: i = 6

In [6]: 

In [7]: i = 7


In [8]: i = 9

In [9]: 

In [10]: 

As you can see, in this instance i = 3 and i = 8 are missing and the commands are out of sync with the input prompts, although the total number of input prompts is correct.

I'm guessing this is a timing issue, and the 'execute_reply' is being received before the corresponding IO operation is complete. Is there a better way to implement automatic execution? Perhaps another signal that is emitted after all processing of a command is completely finished? (I've tried also waiting for a 'status idle' message from the iopub_channel but it didn't help).

I'm using python 3.8 and qtconsole version 5.4.1 (on CentOS 7).