| 74 | return new CodeExecution(code, extensionId); |
| 75 | } |
| 76 | public async start(session: IKernelSession) { |
| 77 | this.session = session; |
| 78 | if (this.cancelHandled) { |
| 79 | traceExecMessage(this.extensionId, this.executionId, 'Not starting as it was cancelled'); |
| 80 | return; |
| 81 | } |
| 82 | traceExecMessage(this.extensionId, this.executionId, 'Start Code execution'); |
| 83 | logger.ci(`Code Exec contents ${this.code.substring(0, 50)}...`); |
| 84 | if (!session.kernel || session.kernel.isDisposed || session.isDisposed) { |
| 85 | this._done.reject(new SessionDisposedError()); |
| 86 | return; |
| 87 | } |
| 88 | |
| 89 | if (this.started) { |
| 90 | traceExecMessage( |
| 91 | this.extensionId, |
| 92 | this.executionId, |
| 93 | 'Code has already been started yet CodeExecution.Start invoked again' |
| 94 | ); |
| 95 | logger.error(`Code has already been started yet CodeExecution.Start invoked again ${this.executionId}`); |
| 96 | // TODO: Send telemetry this should never happen, if it does we have problems. |
| 97 | return this.done; |
| 98 | } |
| 99 | |
| 100 | // Begin the request that will modify our cell. |
| 101 | await this.execute(this.code.replace(/\r\n/g, '\n'), session).catch(noop); |
| 102 | } |
| 103 | |
| 104 | /** |
| 105 | * Cancel execution. |