Description
When threads are created that give output after the main thread is finished, some issues come up about how to treat iopub messages after an execute_reply message. The spec is ambiguous on this point.
The most relevant paragraph of the spec (http://jupyter-client.readthedocs.io/en/latest/messaging.html#execute) says:
Upon completion of the execution request, the kernel always sends a reply, with a status code indicating what happened and additional data depending on the outcome. See below for the possible return codes and associated data.
In the classic notebook, iopub messages after an execute_reply message are processed as normal (i.e., output callbacks still seem to be called so output still shows up in a cell).
In JupyterLab, iopub messages after an execute_reply message are handled until the cell has a new execution. (CC @blink1073; relevant links: https://github.com/jupyterlab/jupyterlab/blob/cec1d9ea9eaae73bba03f6a761b5a2c86b7f1907/packages/outputarea/src/widget.ts#L476 is where code execution is done, which preserves the future until the output has another execution)
I think we should have an official interpretation in the spec of how iopub messages should be handled after execute_reply messages are sent.
Another question is how iopub messages are treated when they are in response to a comm message. It appears in JLab that the iopub callback mechanism is disposed when the idle status is received (https://github.com/jupyterlab/jupyterlab/blob/50be3c38fdf5d82efb06d415dc8ede85aed17edd/packages/services/src/kernel/comm.ts#L140 - disposeOnDone, the third argument, is true). In the classic notebook, it appears that the iopub is still handled when the comm send is finished and the status is idle.
@rgbkrk - how does nteract handle this output from either a comm message or a execute request after the execute_reply/status idle messages?
CC @nleclercq - who was discussing this issue on the jupyter-widgets/Lobby gitter.