mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-26 01:25:38 -05:00
Restart kernel initial implementation (#18835)
* Restart kernel initial implementation * Update notebook extension TestKernel * PR comments
This commit is contained in:
@@ -323,16 +323,27 @@ export class ClientSession implements IClientSession {
|
||||
/**
|
||||
* Restart the session.
|
||||
*
|
||||
* @returns A promise that resolves with whether the kernel has restarted.
|
||||
* @returns A promise that resolves when the kernel has restarted.
|
||||
*
|
||||
* #### Notes
|
||||
* If there is a running kernel, present a dialog.
|
||||
* If there is no kernel, we start a kernel with the last run
|
||||
* kernel name and resolves with `true`. If no kernel has been started,
|
||||
* this is a no-op, and resolves with `false`.
|
||||
* If there is an existing kernel, restart it and resolve.
|
||||
* If no kernel has been started, this is a no-op, and resolves.
|
||||
* Reject on error.
|
||||
*/
|
||||
restart(): Promise<boolean> {
|
||||
throw new Error('Not implemented');
|
||||
restart(): Promise<void> {
|
||||
if (!this._session?.kernel) {
|
||||
// no-op if no kernel is present
|
||||
return Promise.resolve();
|
||||
}
|
||||
let restartCompleted = new Deferred<void>();
|
||||
this._session?.kernel?.restart().then(() => {
|
||||
this.options.notificationService.info(localize('kernelRestartedSuccessfully', 'Kernel restarted successfully'));
|
||||
restartCompleted.resolve();
|
||||
}, err => {
|
||||
this.options.notificationService.error(localize('kernelRestartFailed', 'Kernel restart failed: {0}', err));
|
||||
restartCompleted.reject(err);
|
||||
});
|
||||
return restartCompleted.promise;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -179,15 +179,14 @@ export interface IClientSession extends IDisposable {
|
||||
/**
|
||||
* Restart the session.
|
||||
*
|
||||
* @returns A promise that resolves with whether the kernel has restarted.
|
||||
* @returns A promise that resolves when the kernel has restarted.
|
||||
*
|
||||
* #### Notes
|
||||
* If there is a running kernel, present a dialog.
|
||||
* If there is no kernel, we start a kernel with the last run
|
||||
* kernel name and resolves with `true`. If no kernel has been started,
|
||||
* this is a no-op, and resolves with `false`.
|
||||
* If there is an existing kernel, restart it and resolve.
|
||||
* If no kernel has been started, this is a no-op, and resolves.
|
||||
* Reject on error.
|
||||
*/
|
||||
restart(): Promise<boolean>;
|
||||
restart(): Promise<void>;
|
||||
|
||||
/**
|
||||
* Change the session path.
|
||||
|
||||
@@ -382,6 +382,10 @@ class SqlKernel extends Disposable implements nb.IKernel {
|
||||
});
|
||||
}
|
||||
|
||||
restart(): Thenable<void> {
|
||||
return Promise.reject(localize('SqlKernelRestartNotSupported', 'SQL kernel restart not supported'));
|
||||
}
|
||||
|
||||
private addQueryEventListeners(queryRunner: QueryRunner): void {
|
||||
this._register(queryRunner.onQueryEnd(() => {
|
||||
this.queryComplete().catch(error => {
|
||||
|
||||
Reference in New Issue
Block a user