Skip to content

Commit 2e8dc67

Browse files
author
Kartik Raj
authored
Add extra logging regarding interpreter discovery (#21639)
For #21310
1 parent fc1c391 commit 2e8dc67

File tree

8 files changed

+15
-1
lines changed

8 files changed

+15
-1
lines changed

src/client/common/process/rawProcessApis.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ export function plainExec(
100100
const deferred = createDeferred<ExecutionResult<string>>();
101101
const disposable: IDisposable = {
102102
dispose: () => {
103-
if (!proc.killed && !deferred.completed) {
103+
if (!proc.killed) {
104104
proc.kill();
105105
}
106106
},
@@ -156,10 +156,12 @@ export function plainExec(
156156
deferred.resolve({ stdout, stderr });
157157
}
158158
internalDisposables.forEach((d) => d.dispose());
159+
disposable.dispose();
159160
});
160161
proc.once('error', (ex) => {
161162
deferred.reject(ex);
162163
internalDisposables.forEach((d) => d.dispose());
164+
disposable.dispose();
163165
});
164166

165167
return deferred.promise;

src/client/common/utils/async.ts

+6
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,17 @@ class DeferredImpl<T> implements Deferred<T> {
5050
}
5151

5252
public resolve(_value: T | PromiseLike<T>) {
53+
if (this.completed) {
54+
return;
55+
}
5356
this._resolve.apply(this.scope ? this.scope : this, [_value]);
5457
this._resolved = true;
5558
}
5659

5760
public reject(_reason?: string | Error | Record<string, unknown>) {
61+
if (this.completed) {
62+
return;
63+
}
5864
this._reject.apply(this.scope ? this.scope : this, [_reason]);
5965
this._rejected = true;
6066
}

src/client/pythonEnvironments/base/locators/lowLevel/activeStateLocator.ts

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export class ActiveStateLocator extends LazyResourceBasedLocator {
2020
traceVerbose(`Couldn't locate the state binary.`);
2121
return;
2222
}
23+
traceVerbose(`Searching for active state environments`);
2324
const projects = await state.getProjects();
2425
if (projects === undefined) {
2526
traceVerbose(`Couldn't fetch State Tool projects.`);

src/client/pythonEnvironments/base/locators/lowLevel/microsoftStoreLocator.ts

+1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ export class MicrosoftStoreLocator extends FSWatchingLocator {
8787

8888
protected doIterEnvs(): IPythonEnvsIterator<BasicEnvInfo> {
8989
const iterator = async function* (kind: PythonEnvKind) {
90+
traceVerbose('Searching for windows store envs');
9091
const exes = await getMicrosoftStorePythonExes();
9192
yield* exes.map(async (executablePath: string) => ({
9293
kind,

src/client/pythonEnvironments/base/locators/lowLevel/posixKnownPathsLocator.ts

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export class PosixKnownPathsLocator extends Locator<BasicEnvInfo> {
2626
}
2727

2828
const iterator = async function* (kind: PythonEnvKind) {
29+
traceVerbose('Searching for interpreters in posix paths locator');
2930
// Filter out pyenv shims. They are not actual python binaries, they are used to launch
3031
// the binaries specified in .python-version file in the cwd. We should not be reporting
3132
// those binaries as environments.

src/client/pythonEnvironments/base/locators/lowLevel/pyenvLocator.ts

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { traceError, traceVerbose } from '../../../../logging';
1616
* all the environments (global or virtual) in that directory.
1717
*/
1818
async function* getPyenvEnvironments(): AsyncIterableIterator<BasicEnvInfo> {
19+
traceVerbose('Searching for pyenv environments');
1920
const pyenvVersionDir = getPyenvVersionsDir();
2021

2122
const subDirs = getSubDirs(pyenvVersionDir, { resolveSymlinks: true });

src/client/pythonEnvironments/base/locators/lowLevel/windowsKnownPathsLocator.ts

+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ function getDirFilesLocator(
9393
// rather than in each low-level locator. In the meantime we
9494
// take a naive approach.
9595
async function* iterEnvs(query: PythonLocatorQuery): IPythonEnvsIterator<BasicEnvInfo> {
96+
traceVerbose('Searching for windows path interpreters');
9697
yield* await getEnvs(locator.iterEnvs(query));
9798
traceVerbose('Finished searching for windows path interpreters');
9899
}

src/client/pythonEnvironments/base/locators/lowLevel/windowsRegistryLocator.ts

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export class WindowsRegistryLocator extends Locator<BasicEnvInfo> {
1414
// eslint-disable-next-line class-methods-use-this
1515
public iterEnvs(): IPythonEnvsIterator<BasicEnvInfo> {
1616
const iterator = async function* () {
17+
traceVerbose('Searching for windows registry interpreters');
1718
const interpreters = await getRegistryInterpreters();
1819
for (const interpreter of interpreters) {
1920
try {

0 commit comments

Comments
 (0)