Skip to content
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
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,7 @@
"prettier.tabWidth": 4,
"python-envs.defaultEnvManager": "ms-python.python:venv",
"python-envs.pythonProjects": [],
"git.branchRandomName.enable": true
"git.branchRandomName.enable": true,
"git.branchProtection": ["main"],
"git.branchProtectionPrompt": "alwaysCommitToNewBranch"
}
10 changes: 6 additions & 4 deletions src/managers/common/nativePythonFinder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ class NativePythonFinderImpl implements NativePythonFinder {
private readonly connection: rpc.MessageConnection;
private readonly pool: WorkerPool<NativePythonEnvironmentKind | Uri[] | undefined, NativeInfo[]>;
private cache: Map<string, NativeInfo[]> = new Map();
private readonly startDisposables: Disposable[] = [];

constructor(
private readonly outputChannel: LogOutputChannel,
Expand Down Expand Up @@ -192,6 +193,8 @@ class NativePythonFinderImpl implements NativePythonFinder {
}

public dispose() {
this.pool.stop();
this.startDisposables.forEach((d) => d.dispose());
this.connection.dispose();
}

Expand Down Expand Up @@ -221,14 +224,13 @@ class NativePythonFinderImpl implements NativePythonFinder {
// we have got the exit event.
const readable = new PassThrough();
const writable = new PassThrough();
const disposables: Disposable[] = [];
try {
const proc = spawnProcess(this.toolPath, ['server'], { env: process.env, stdio: 'pipe' });
proc.stdout.pipe(readable, { end: false });
proc.stderr.on('data', (data) => this.outputChannel.error(`[pet] ${data.toString()}`));
writable.pipe(proc.stdin, { end: false });

disposables.push({
this.startDisposables.push({
dispose: () => {
try {
if (proc.exitCode === null) {
Expand All @@ -246,7 +248,7 @@ class NativePythonFinderImpl implements NativePythonFinder {
new rpc.StreamMessageReader(readable),
new rpc.StreamMessageWriter(writable),
);
disposables.push(
this.startDisposables.push(
connection,
new Disposable(() => {
readable.end();
Expand Down Expand Up @@ -276,7 +278,7 @@ class NativePythonFinderImpl implements NativePythonFinder {
}),
connection.onNotification('telemetry', (data) => this.outputChannel.info('[pet] Telemetry: ', data)),
connection.onClose(() => {
disposables.forEach((d) => d.dispose());
this.startDisposables.forEach((d) => d.dispose());
}),
);

Expand Down
Loading