Skip to content

Commit

Permalink
WIP reworking the kernel status.
Browse files Browse the repository at this point in the history
  • Loading branch information
jasongrout committed Jul 19, 2018
1 parent 6d58acf commit 96fc99b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/services/src/kernel/default.ts
Expand Up @@ -811,6 +811,18 @@ export class DefaultKernel implements Kernel.IKernel {

/**
* Handle status iopub messages from the kernel.
*
* The statuses are:
* - starting: only initially
* - idle/busy: status messages from the kernel
* - connected: Kernel socket is connected and ready to send/receive messages
* - restarting: Kernel is currently restarting
* - reconnecting: The kernel connection is down, but it is reconnecting
* - dead: we've given up trying to connect to the kernel, and it is disposed.
*
* - Restarting: restarting -> reconnecting -> connected -> idle (after first
* request)
* - Initial state: unkown -> starting ->
*/
private _updateStatus(status: Kernel.Status): void {
switch (status) {
Expand Down
23 changes: 23 additions & 0 deletions packages/services/src/kernel/kernel.ts
Expand Up @@ -920,6 +920,29 @@ export namespace Kernel {

/**
* The valid Kernel status states.
*
* - unknown: the initial starting state
* - connecting: the frontend is in the process of connecting to the backend
* - idle: the kernel sent a status idle message. This is the default 'resting' state
* - busy: the kernel sent a status busy message
* - restarting: the kernel sent a restarting message, which indicates an
* automatic restart
* - dead: the kernel issued a dead message, *OR* we've given up on connecting
* to it.
* - connected: set when we first connect to the kernel (possibly after
* restart or some connection failure)
*
* Some common sequences:
* - Intial state: unknown
* - Connection (initial connection or reconnection): connecting -> connected -> idle
* - User-initiated restart: restarting -> (post restart request) -> connecting -> connected -> idle
* - Kernel-initiated restart: autostarting -> connecting -> connected -> idle
* - Execution: (send message) -> busy -> idle
* - Interrupt: ?
* - Shutdown: dead
*
* TODO: special-case initial kernel_info_request messages to not change the busy state until we are done processing them. What happens if we receive iopub messages before we are officially connected with the kernel_info_request?
*
*/
export type Status =
| 'unknown'
Expand Down

0 comments on commit 96fc99b

Please sign in to comment.