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

Function dispose

src/kernels/kernel.ts:326–366  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

324 }
325 }
326 public async dispose(): Promise<void> {
327 logger.info(
328 `Dispose Kernel '${getDisplayPath(this.uri)}' associated with '${getDisplayPath(this.resourceUri)}'`
329 );
330 this._disposing = true;
331 if (this.disposingPromise) {
332 return this.disposingPromise;
333 }
334 this._ignoreJupyterSessionDisposedErrors = true;
335 this.startCancellation.cancel();
336 const disposeImpl = async () => {
337 const promises: Promise<void>[] = [];
338 promises.push(
339 Promise.all(Array.from(this.hooks.get('willCancel') || new Set<Hook>()).map((h) => h()))
340 .then(noop)
341 .catch(noop)
342 );
343 this._session = this._session
344 ? this._session
345 : this._jupyterSessionPromise
346 ? await this._jupyterSessionPromise.catch(() => undefined)
347 : undefined;
348 this._jupyterSessionPromise = undefined;
349 this._postInitializedOnStartPromise = undefined;
350 if (this._session) {
351 promises.push(disposeAsync(this._session, this.disposables));
352 this._session = undefined;
353 }
354 this._disposed = true;
355 this._onDisposed.fire();
356 this._onStatusChanged.fire('dead');
357 try {
358 await Promise.all(promises);
359 } finally {
360 this.startCancellation.dispose();
361 dispose(this.disposables);
362 }
363 };
364 this.disposingPromise = disposeImpl();
365 await this.disposingPromise;
366 }
367 public async restart(): Promise<void> {
368 try {
369 const resourceType = getResourceType(this.resourceUri);

Callers

nothing calls this directly

Calls 4

getDisplayPathFunction · 0.90
disposeImplFunction · 0.85
infoMethod · 0.65
cancelMethod · 0.65

Tested by

no test coverage detected