()
| 652 | } |
| 653 | |
| 654 | private async createJupyterSession(): Promise<IKernelSession> { |
| 655 | const notebook = workspace.notebookDocuments.find((item) => item.uri.toString() === this.uri.toString()); |
| 656 | const telemetryTracker = notebook |
| 657 | ? getNotebookTelemetryTracker(notebook)?.jupyterSessionTelemetry() |
| 658 | : undefined; |
| 659 | await trackKernelResourceInformation(this.resourceUri, { |
| 660 | kernelConnection: this.kernelConnectionMetadata, |
| 661 | actionSource: this.creator, |
| 662 | // This means the user is actually running something against the kernel (deliberately). |
| 663 | userExecutedCell: !this.startupUI.disableUI |
| 664 | }); |
| 665 | telemetryTracker?.stop(); |
| 666 | if (this.disposing) { |
| 667 | throw new CancellationError(); |
| 668 | } |
| 669 | Cancellation.throwIfCanceled(this.startCancellation.token); |
| 670 | let disposables: Disposable[] = []; |
| 671 | try { |
| 672 | logger.info(`Starting Kernel ${getKernelStartupLogMessage(this, this.startupUI)}`); |
| 673 | this.createProgressIndicator(disposables); |
| 674 | this.isKernelDead = false; |
| 675 | this._onStatusChanged.fire('starting'); |
| 676 | const session = await this.sessionCreator.create({ |
| 677 | resource: this.resourceUri, |
| 678 | ui: this.startupUI, |
| 679 | kernelConnection: this.kernelConnectionMetadata, |
| 680 | token: this.startCancellation.token, |
| 681 | creator: this.creator |
| 682 | }); |
| 683 | if (this.disposing) { |
| 684 | throw new CancellationError(); |
| 685 | } |
| 686 | Cancellation.throwIfCanceled(this.startCancellation.token); |
| 687 | await this.initializeAfterStart(session); |
| 688 | if (this.disposing) { |
| 689 | throw new CancellationError(); |
| 690 | } |
| 691 | this.sendKernelStartedTelemetry(); |
| 692 | this._session = session; |
| 693 | this._onStarted.fire(); |
| 694 | logger.info(`Kernel successfully started`); |
| 695 | return session; |
| 696 | } catch (ex) { |
| 697 | // Don't log errors if UI is disabled (e.g. auto starting a kernel) |
| 698 | // Else we just pollute the logs with lots of noise. |
| 699 | if (this.startupUI.disableUI) { |
| 700 | logger.trace( |
| 701 | `failed to create IJupyterKernelConnectionSession in kernel, UI Disabled = ${this.startupUI.disableUI}`, |
| 702 | ex |
| 703 | ); |
| 704 | } else if (!this.startCancellation.token && !isCancellationError(ex)) { |
| 705 | logger.error( |
| 706 | `failed to create IJupyterKernelConnectionSession in kernel, UI Disabled = ${this.startupUI.disableUI}`, |
| 707 | ex |
| 708 | ); |
| 709 | } |
| 710 | Cancellation.throwIfCanceled(this.startCancellation.token); |
| 711 | if (ex instanceof JupyterConnectError) { |
nothing calls this directly
no test coverage detected