|
@@ -142,6 +142,13 @@ export class KernelConnection implements Kernel.IKernelConnection {
|
|
|
return this._anyMessage;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * A signal emitted when a kernel has pending inputs from the user.
|
|
|
+ */
|
|
|
+ get pendingInput(): ISignal<this, boolean> {
|
|
|
+ return this._pendingInput;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* The id of the server-side kernel.
|
|
|
*/
|
|
@@ -437,6 +444,7 @@ export class KernelConnection implements Kernel.IKernelConnection {
|
|
|
* request fails or the response is invalid.
|
|
|
*/
|
|
|
async interrupt(): Promise<void> {
|
|
|
+ this.hasPendingInput = false;
|
|
|
if (this.status === 'dead') {
|
|
|
throw new Error('Kernel is dead');
|
|
|
}
|
|
@@ -472,6 +480,7 @@ export class KernelConnection implements Kernel.IKernelConnection {
|
|
|
// Reconnect to the kernel to address cases where kernel ports
|
|
|
// have changed during the restart.
|
|
|
await this.reconnect();
|
|
|
+ this.hasPendingInput = false;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -815,6 +824,8 @@ export class KernelConnection implements Kernel.IKernelConnection {
|
|
|
|
|
|
this._sendMessage(msg);
|
|
|
this._anyMessage.emit({ msg, direction: 'send' });
|
|
|
+
|
|
|
+ this.hasPendingInput = false;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -955,6 +966,13 @@ export class KernelConnection implements Kernel.IKernelConnection {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Remove the input guard, if any.
|
|
|
+ */
|
|
|
+ removeInputGuard() {
|
|
|
+ this.hasPendingInput = false;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Handle a message with a display id.
|
|
|
*
|
|
@@ -1501,6 +1519,14 @@ export class KernelConnection implements Kernel.IKernelConnection {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+ get hasPendingInput(): boolean {
|
|
|
+ return this._hasPendingInput;
|
|
|
+ }
|
|
|
+ set hasPendingInput(value: boolean) {
|
|
|
+ this._hasPendingInput = value;
|
|
|
+ this._pendingInput.emit(value);
|
|
|
+ }
|
|
|
+
|
|
|
private _id = '';
|
|
|
private _name = '';
|
|
|
private _status: KernelMessage.Status = 'unknown';
|
|
@@ -1541,10 +1567,12 @@ export class KernelConnection implements Kernel.IKernelConnection {
|
|
|
private _disposed = new Signal<this, void>(this);
|
|
|
private _iopubMessage = new Signal<this, KernelMessage.IIOPubMessage>(this);
|
|
|
private _anyMessage = new Signal<this, Kernel.IAnyMessageArgs>(this);
|
|
|
+ private _pendingInput = new Signal<this, boolean>(this);
|
|
|
private _unhandledMessage = new Signal<this, KernelMessage.IMessage>(this);
|
|
|
private _displayIdToParentIds = new Map<string, string[]>();
|
|
|
private _msgIdToDisplayIds = new Map<string, string[]>();
|
|
|
private _msgChain: Promise<void> = Promise.resolve();
|
|
|
+ private _hasPendingInput = false;
|
|
|
private _noOp = () => {
|
|
|
/* no-op */
|
|
|
};
|