Description
Frontend applications should be able to fetch the lifecycle states (starting, connecting, connected, terminating, dead, restarting, ...) and execution states (busy, idle, etc.) of a given kernel. The server should be in charge of resolving these states, since it talks directly to the kernel.
As mentioned in previous issue, today, frontends are forced to resolve the kernel states by tracking IOPub status messages. There are many problems with relying on the client to listen to the IOPub stream. See that issue for more details.
I propose that we make Jupyter Server's kernel manager responsible for storing, tracking, and returning the state of its kernel. We should add a REST API to the kernels service to fetch the state of a kernel, e.g.
GET /api/kernels/{kernel-id}/state
RESPONSE:
{
"execution_state": "idle",
"lifecycle_state": "connected"
}
We can also consider leveraging the Jupyter Event system to emit notifications with the kernel state changes.
This proposal would address #989