MCPcopy Create free account
hub / github.com/deepnote/vscode-deepnote / CellExecution

Class CellExecution

src/kernels/execution/cellExecution.ts:82–585  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80 *
81 */
82export class CellExecution implements ICellExecution, IDisposable {
83 public readonly type = 'cell';
84 public get result(): Promise<void> {
85 return this._result.promise;
86 }
87 private readonly _result = createDeferred<void>();
88
89 private started?: boolean;
90
91 private _completed?: boolean;
92 private endTime?: number;
93 private execution?: NotebookCellExecution & {
94 /**
95 * Whether we have received a response for the execution request sent to the kernel.
96 * I.e. has the kernel acknowledged the execution request.
97 */
98 started?: boolean;
99 };
100 private cancelHandled = false;
101 private disposed?: boolean;
102 private request: Kernel.IShellFuture<KernelMessage.IExecuteRequestMsg, KernelMessage.IExecuteReplyMsg> | undefined;
103 private readonly disposables: IDisposable[] = [];
104 private cellExecutionHandler?: CellExecutionMessageHandler;
105 private session?: IKernelSession;
106 private cancelRequested?: boolean;
107 private _executionOrder?: number;
108 public get executionOrder() {
109 return this._executionOrder;
110 }
111 private constructor(
112 public readonly cell: NotebookCell,
113 private readonly codeOverride: string | undefined,
114 private readonly kernelConnection: Readonly<KernelConnectionMetadata>,
115 private readonly controller: IKernelController,
116 private readonly requestListener: CellExecutionMessageHandlerService,
117 private readonly resumeExecution?: ResumeCellExecutionInformation,
118 private readonly federatedAuthSqlBlockCodeGenerator?: IFederatedAuthSqlBlockCodeGenerator
119 ) {
120 workspace.onDidCloseTextDocument(
121 (e) => {
122 // If the cell is deleted, then dispose the request object.
123 // No point keeping it alive, just chewing resources.
124 if (e === this.cell.document) {
125 logger.info(
126 `Disposing request as the cell (${this.cell.index}) was deleted ${getDisplayPath(
127 this.cell.notebook.uri
128 )}`
129 );
130 try {
131 this.request?.dispose(); // NOSONAR
132 } catch (e) {
133 logger.error(`Error during cell execution dispose: ${e}`);
134 }
135 if (this.started && !this._completed) {
136 this.completedDueToCancellation();
137 }
138 }
139 },

Callers

nothing calls this directly

Calls 1

createDeferredFunction · 0.90

Tested by

no test coverage detected