Commit 564feae7 authored by Romain Casati's avatar Romain Casati
Browse files

Manage pending input in kernel-base.

parent 9d39cf62
......@@ -383,7 +383,11 @@ export class GUIBase {
/**
* Restart the kernel.
*/
public kernelRestart(): void { this.kernelSafe?.restart(); }
public kernelRestart(): void {
if (this.kernelSafe?.pendingInput())
throw new Error("pending input");
this.kernelSafe?.restart();
}
/**
* Load ressources from URL (common part to files and modules).
......
......@@ -31,7 +31,8 @@ export class KernelBase {
private _rootPath: string;
private _ready: boolean = false;
private readonly _loaded = new PromiseDelegate<void>();
public _execution_count: number = 0;
protected _execution_count: number = 0;
protected _pendingInput: boolean = false;
constructor(options: any) {
// root path where kernel is installed
......@@ -215,8 +216,11 @@ export class KernelBase {
data.resolve = resolve;
data.reject = reject;
});
this._pendingInput = true;
this.dispatchEvent("eval.input", data);
return await promise;
const res = await promise;
this._pendingInput = false;
return res;
}
/**
......@@ -240,6 +244,13 @@ export class KernelBase {
}
};
/**
* Is an input pending?
*/
public pendingInput() {
return this._pendingInput;
}
/**
* Internal. Code evaluation after an eval.request event.
*/
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment