Skip to content

Commit

Permalink
fix: load server settings asynchronously
Browse files Browse the repository at this point in the history
  • Loading branch information
agoose77 committed Jan 29, 2024
1 parent 5a5813d commit 4012be5
Showing 1 changed file with 13 additions and 20 deletions.
33 changes: 13 additions & 20 deletions packages/myst-cli/src/session/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,27 +176,20 @@ export class Session implements ISession {
if (this._jupyterSessionManager !== null) {
return Promise.resolve(this._jupyterSessionManager);
}

try {
const partialServerSettings = await new Promise<JupyterServerSettings>((resolve, reject) => {
if (process.env.JUPYTER_BASE_URL === undefined) {
const settings = findExistingJupyterServer();
if (settings) {
console.log('LOADED EXISTING');
return resolve(settings);
} else {
console.log('LAUNCH NEW');
return launchJupyterServer(this.contentPath(), this.log).then((launchedSettings) => {
console.log('LOADED', launchedSettings);
resolve(launchedSettings);
});
}
} else {
resolve({
baseUrl: process.env.JUPYTER_BASE_URL,
token: process.env.JUPYTER_TOKEN,
});
}
});
let partialServerSettings: JupyterServerSettings | undefined;
if (process.env.JUPYTER_BASE_URL !== undefined) {
partialServerSettings = {
baseUrl: process.env.JUPYTER_BASE_URL,
token: process.env.JUPYTER_TOKEN,
};
} else {
partialServerSettings =
(await findExistingJupyterServer()) ||
(await launchJupyterServer(this.contentPath(), this.log));
}

const serverSettings = ServerConnection.makeSettings(partialServerSettings);
const kernelManager = new KernelManager({ serverSettings });
const manager = new SessionManager({ kernelManager, serverSettings });
Expand Down

0 comments on commit 4012be5

Please sign in to comment.