| 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 | } |