Skip to content
This repository has been archived by the owner on Jan 26, 2022. It is now read-only.

Commit

Permalink
Attempt at fixing the tests on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
jtpio committed Jan 14, 2020
1 parent e1da8cc commit 716dc14
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ export class DebugSession implements IDebugger.ISession {
}

this._connection.iopubMessage.connect(this._handleEvent, this);

this._ready = this.connection.kernel.info;
}

/**
Expand Down Expand Up @@ -96,7 +94,7 @@ export class DebugSession implements IDebugger.ISession {
* Start a new debug session
*/
async start(): Promise<void> {
await this._ready;
await this._ready();
await this.sendRequest('initialize', {
clientID: 'jupyterlab',
clientName: 'JupyterLab',
Expand All @@ -119,7 +117,7 @@ export class DebugSession implements IDebugger.ISession {
* Stop the running debug session.
*/
async stop(): Promise<void> {
await this._ready;
await this._ready();
await this.sendRequest('disconnect', {
restart: false,
terminateDebuggee: true
Expand All @@ -131,7 +129,7 @@ export class DebugSession implements IDebugger.ISession {
* Restore the state of a debug session.
*/
async restoreState(): Promise<IDebugger.ISession.Response['debugInfo']> {
await this._ready;
await this._ready();
const message = await this.sendRequest('debugInfo', {});
this._isStarted = message.body.isStarted;
return message;
Expand All @@ -146,7 +144,7 @@ export class DebugSession implements IDebugger.ISession {
command: K,
args: IDebugger.ISession.Request[K]
): Promise<IDebugger.ISession.Response[K]> {
await this._ready;
await this._ready();
const message = await this._sendDebugMessage({
type: 'request',
seq: this._seq++,
Expand Down Expand Up @@ -195,9 +193,15 @@ export class DebugSession implements IDebugger.ISession {
return reply.promise;
}

/**
* A promise that resolves when the kernel is ready.
*/
private _ready() {
return this._connection?.kernel?.info;
}

private _seq = 0;
private _connection: Session.ISessionConnection;
private _ready: Promise<KernelMessage.IInfoReply>;
private _isDisposed = false;
private _isStarted = false;
private _disposed = new Signal<this, void>(this);
Expand Down
1 change: 1 addition & 0 deletions tests/src/session.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ describe('DebugSession', () => {
}
});
await sessionContext.initialize();
await sessionContext.ready;
await sessionContext.session?.kernel?.info;
});

Expand Down

0 comments on commit 716dc14

Please sign in to comment.