Starting Fewer Jupyter Servers for Notebooks (#7744)

* Start fewer Jupyter servers

* Windows fix for drive casing

* PR Feedback

* Quick fix

* Fixing bug

* Ensure environment variables set 4 session startup

* test fix

* Dummy commit to update comment
This commit is contained in:
Chris LaFreniere
2019-10-20 21:38:58 -07:00
committed by GitHub
parent 0bfb1aab7e
commit e3ae5263c6
9 changed files with 118 additions and 43 deletions

View File

@@ -99,7 +99,7 @@ export class ServerInstanceUtils {
}
}
export class PerNotebookServerInstance implements IServerInstance {
export class PerFolderServerInstance implements IServerInstance {
/**
* Root of the jupyter directory structure. Config and data roots will be
@@ -123,6 +123,7 @@ export class PerNotebookServerInstance implements IServerInstance {
private _port: string;
private _uri: vscode.Uri;
private _isStarted: boolean = false;
private _isStopping: boolean = false;
private utils: ServerInstanceUtils;
private childProcess: ChildProcess;
private errorHandler: ErrorHandler = new ErrorHandler();
@@ -132,7 +133,7 @@ export class PerNotebookServerInstance implements IServerInstance {
}
public get isStarted(): boolean {
return this._isStarted;
return this._isStarted && !this._isStopping;
}
public get port(): string {
@@ -153,13 +154,14 @@ export class PerNotebookServerInstance implements IServerInstance {
public async stop(): Promise<void> {
try {
this._isStopping = true;
if (this.baseDir) {
let exists = await this.utils.pathExists(this.baseDir);
if (exists) {
await this.utils.removeDir(this.baseDir);
}
}
if (this.isStarted) {
if (this._isStarted) {
let install = this.options.install;
let stopCommand = `"${install.pythonExecutable}" -m jupyter notebook stop ${this._port}`;
await this.utils.executeBufferedCommand(stopCommand, install.execOptions, install.outputChannel);
@@ -171,6 +173,7 @@ export class PerNotebookServerInstance implements IServerInstance {
this._isStarted = false;
this.utils.ensureProcessEnded(this.childProcess);
this.handleConnectionClosed();
}
}