Skip to content

Do not expose kernel process #11282

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/client/datascience/kernel-launcher/kernelLauncher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ class KernelProcess implements IKernelProcess {
public get kernelSpec(): Readonly<IJupyterKernelSpec> {
return this._kernelSpec;
}
public get process(): ChildProcess | undefined {
return this._process;
}
public get connection(): Readonly<IKernelConnection> {
return this._connection;
}
Expand Down
2 changes: 0 additions & 2 deletions src/client/datascience/kernel-launcher/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT License.
'use strict';

import { ChildProcess } from 'child_process';
import { IDisposable } from 'monaco-editor';
import { Event } from 'vscode';
import { InterpreterUri } from '../../common/installer/types';
Expand All @@ -27,7 +26,6 @@ export interface IKernelConnection {
}

export interface IKernelProcess extends IDisposable {
process: ChildProcess | undefined;
readonly connection: Readonly<IKernelConnection>;
ready: Promise<void>;
readonly kernelSpec: Readonly<IJupyterKernelSpec>;
Expand Down
33 changes: 28 additions & 5 deletions src/test/datascience/kernelLauncher.functional.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import { assert } from 'chai';
import { Uri } from 'vscode';

import { ChildProcess } from 'child_process';
import { IFileSystem } from '../../client/common/platform/types';
import { IPythonExecutionFactory } from '../../client/common/process/types';
import { Resource } from '../../client/common/types';
Expand All @@ -14,7 +13,7 @@ import { JupyterZMQBinariesNotFoundError } from '../../client/datascience/jupyte
import { KernelLauncher } from '../../client/datascience/kernel-launcher/kernelLauncher';
import { IKernelConnection, IKernelFinder } from '../../client/datascience/kernel-launcher/types';
import { InterpreterType, PythonInterpreter } from '../../client/interpreter/contracts';
import { PYTHON_PATH, sleep } from '../common';
import { PYTHON_PATH, sleep, waitForCondition } from '../common';
import { DataScienceIocContainer } from './dataScienceIocContainer';

suite('Kernel Launcher', () => {
Expand Down Expand Up @@ -50,25 +49,49 @@ suite('Kernel Launcher', () => {
this.skip();
} else {
const kernel = await kernelLauncher.launch(resource, kernelName);
const exited = new Promise<boolean>((resolve) => kernel.exited(() => resolve(true)));

assert.isOk<IKernelConnection | undefined>(kernel.connection, 'Connection not found');
assert.isOk<ChildProcess | undefined>(kernel.process, 'Child Process not found');

// It should not exit.
assert.isRejected(
waitForCondition(() => exited, 5_000, 'Timeout'),
'Timeout'
);

// Upon disposing, we should get an exit event within 100ms or less.
// If this happens, then we know a process existed.
kernel.dispose();
assert.isRejected(
waitForCondition(() => exited, 100, 'Timeout'),
'Timeout'
);
}
});
}).timeout(10_000);

test('Launch from PythonInterpreter', async function () {
if (!process.env.VSCODE_PYTHON_ROLLING) {
// tslint:disable-next-line: no-invalid-this
this.skip();
} else {
const kernel = await kernelLauncher.launch(pythonInterpreter, kernelName);
const exited = new Promise<boolean>((resolve) => kernel.exited(() => resolve(true)));

// It should not exit.
assert.isRejected(
waitForCondition(() => exited, 5_000, 'Timeout'),
'Timeout'
);

assert.isOk<IKernelConnection | undefined>(kernel.connection, 'Connection not found');
assert.isOk<ChildProcess | undefined>(kernel.process, 'Child Process not found');

// Upon disposing, we should get an exit event within 100ms or less.
// If this happens, then we know a process existed.
kernel.dispose();
assert.isRejected(
waitForCondition(() => exited, 100, 'Timeout'),
'Timeout'
);
}
});

Expand Down