Hi Vladimir,
Xeus developer here. I think that you understood really well the constraints with respect to concurrency for the debugger.
The choice of the Control channel
- the Shell channel is out of question because debug messages would end up being queued with the rest of the shell messages (such as execution requests and comm messages).
- while the Control channel does not have that requirement, which is actually the main reason for its existence as the goal was to be able to send shutdown or interrupt messages while code is queued for execution.
This is the reason why we decided to use Control as the main channel for debug messages.
The Concurrency Model and Xeus
An issue with the current state of ipykernel is that the concurrency model is that of an event loop, meaning that any blocking code execution triggered by a shell message would prevent control messages to be processed. What we want is to be able to add a breakpoint while code is running, for example in a long-running loop, and see the debugger stop at the next iteration of that loop. For this reason, we need to use a separate thread to process control messages.
Xeus is a C++ implementation of the Jupyter protocol. It is not a kernel but a library facilitating the implementation of kernels. Kernels built with xeus include
xeus-cling (a C++ kernel),
xeus-python (A Python kernel), and more. It has a pluggable concurrency model (which can be changed by providing one's own implementation of the "xserver" base class). For example,
Kitware built a custom python kernel with xeus that integrates into the Qt event loop for their Slicer kernel...
Xeus-python, the xeus-based python kernel supports most of the features of ipykernel (rich display, widgets, auto-complete, rich tracebacks, quick-help etc), and provides a debugging backend for the messages of DAP (Debug Adaptor Protocol) over control messages as explained by Afshin earlier.
In order to route these control messages from the backend to the web front-end, several pull requests have been opened, and merged in jupyter_client, notebook, jupyter_server, jupyterlab. A really good summary of that work was done by Johan Mabille here:
https://github.com/jupyter/jupyter_client/issues/446.
Another advantage of xeus-python is that it is a much smaller codebase to iterate upon. The entire kernel is about 3k lines of code with a good coverage of the features (rich display, widgets, auto-complete, rich tracebacks, quick-help), and we could iterate quickly. We are looking at moving xeus, xeus-python, and xeus-cling in a different github organization under the Jupyter governance.
The Ongoing Frontend Work
We are now working on the front-end component to that stack. This part is mostly done by Afshin Darian, Jeremy Tuloup, Borys Palka, and Johan Mabille.
In the screencast below, you can see the state that was demoed by Jeremy at EuroScipy a couple of weeks ago.
There is still a lot to figure out with respect to the UX of the debugger, the lifecycle of debugging sessions etc, which may require more backend work as well (such as storing the debugger state etc). And we take help!
PTVSD actually is a layer on the top of pydevd, which is the debugger also used by pycharm and eclipse. It seems that layers are only ever added... In fact, I think that in the end, once the whole front-end is complete, we could rework some aspects of that and directly use pydev (even though we make use of the debug adaptor specification for the frontend messaging).
Looking forward to hearing back from you!