Skip to content

Interrupting a kernel vs Cancelling cell execution #106741

@jrieken

Description

@jrieken

With #99203 we have removed cancellation tokens from the execute-functions and replaced them with cancel-function. This was done because jupyter kernels don't have the notion of canceling an execution but a notion of interrupting the kernel. Those are two different things and the current API is a compromise to fit both worlds. The compromise isn't happy:

  1. for notebooks that support cancellation of execution things are now much more complex because the cancellation isn't automatically associated with an execution anymore.
  2. for jupyter kernels it doesn't make sense to implement cancelAllCellsExecution and cancelCellExecution because both are doing the same thing, sending an interrupt to the kernel.

The API should be more explicit in support interrupting kernels. Proposal

export interface NotebookKernel {

  executeCell(document: NotebookDocument, cell: NotebookCell, token: CancellationToken): void;
  executeAllCells(document: NotebookDocument, token: CancellationToken): void;

  interruptExecution?(document: NotebookDocument): void;
}

A notebook kernel can optionally implement an interrupt-function which signals to us that it uses an interrupt model (e.g in the UI all stop buttons call interrupt). The execute-function do have cancellation tokens but the contract would be that they are null-token when using the interrupt model.

Metadata

Metadata

Assignees

Labels

*duplicateIssue identified as a duplicate of another issue(s)apinotebookunder-discussionIssue is under discussion for relevance, priority, approach

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions