Skip to content

Commit 2442dfb

Browse files
author
Kartik Raj
authored
Add logging which could help indicate why Discovering Python Interpreters... never finishes (#20792)
For #20250
1 parent e8303bb commit 2442dfb

19 files changed

+25
-12
lines changed

src/client/pythonEnvironments/base/locators/composite/envsReducer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ function checkIfFinishedAndNotify(
129129
if (state.done && state.pending === 0) {
130130
didUpdate.fire({ stage: ProgressReportStage.discoveryFinished });
131131
didUpdate.dispose();
132+
traceVerbose(`Finished with environment reducer`);
132133
}
133134
}
134135

src/client/pythonEnvironments/base/locators/composite/envsResolver.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ function checkIfFinishedAndNotify(
174174
if (state.done && state.pending === 0) {
175175
didUpdate.fire({ stage: ProgressReportStage.discoveryFinished });
176176
didUpdate.dispose();
177+
traceVerbose(`Finished with environment resolver`);
177178
}
178179
}
179180

src/client/pythonEnvironments/base/locators/lowLevel/activestateLocator.ts renamed to src/client/pythonEnvironments/base/locators/lowLevel/activeStateLocator.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,6 @@ export class ActiveStateLocator extends LazyResourceBasedLocator {
4040
}
4141
}
4242
}
43+
traceVerbose(`Finished searching for active state environments`);
4344
}
4445
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,6 @@ export class CondaEnvironmentLocator extends FSWatchingLocator {
3838
traceError(`Failed to process conda env: ${JSON.stringify(env)}`, ex);
3939
}
4040
}
41+
traceVerbose(`Finished searching for conda environments`);
4142
}
4243
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ export class CustomVirtualEnvironmentLocator extends FSWatchingLocator {
132132
});
133133

134134
yield* iterable(chain(envGenerators));
135+
traceVerbose(`Finished searching for custom virtual envs`);
135136
}
136137

137138
return iterator();

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ export class GlobalVirtualEnvironmentLocator extends FSWatchingLocator {
134134
});
135135

136136
yield* iterable(chain(envGenerators));
137+
traceVerbose(`Finished searching for global virtual envs`);
137138
}
138139

139140
return iterator();

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
isStorePythonInstalled,
1313
getMicrosoftStoreAppsRoot,
1414
} from '../../../common/environmentManagers/microsoftStoreEnv';
15+
import { traceVerbose } from '../../../../logging';
1516

1617
/**
1718
* This is a glob pattern which matches following file names:
@@ -91,6 +92,7 @@ export class MicrosoftStoreLocator extends FSWatchingLocator {
9192
kind,
9293
executablePath,
9394
}));
95+
traceVerbose(`Finished searching for windows store envs`);
9496
};
9597
return iterator(this.kind);
9698
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export class PoetryLocator extends LazyResourceBasedLocator {
7070
});
7171

7272
yield* iterable(chain(envGenerators));
73+
traceVerbose(`Finished searching for poetry envs`);
7374
}
7475

7576
return iterator(this.root);

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import { BasicEnvInfo, IPythonEnvsIterator, Locator } from '../../locator';
88
import { commonPosixBinPaths, getPythonBinFromPosixPaths } from '../../../common/posixUtils';
99
import { isPyenvShimDir } from '../../../common/environmentManagers/pyenv';
1010
import { getOSType, OSType } from '../../../../common/utils/platform';
11-
import { isMacDefaultPythonPath } from './macDefaultLocator';
12-
import { traceError } from '../../../../logging';
11+
import { isMacDefaultPythonPath } from '../../../common/environmentManagers/macDefault';
12+
import { traceError, traceVerbose } from '../../../../logging';
1313

1414
export class PosixKnownPathsLocator extends Locator<BasicEnvInfo> {
1515
public readonly providerId = 'posixKnownPaths';
@@ -44,6 +44,7 @@ export class PosixKnownPathsLocator extends Locator<BasicEnvInfo> {
4444
traceError(`Failed to process environment: ${bin}`, ex);
4545
}
4646
}
47+
traceVerbose('Finished searching for interpreters in posix paths locator');
4748
};
4849
return iterator(this.kind);
4950
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { FSWatchingLocator } from './fsWatchingLocator';
77
import { getInterpreterPathFromDir } from '../../../common/commonUtils';
88
import { getSubDirs } from '../../../common/externalDependencies';
99
import { getPyenvVersionsDir } from '../../../common/environmentManagers/pyenv';
10-
import { traceError } from '../../../../logging';
10+
import { traceError, traceVerbose } from '../../../../logging';
1111

1212
/**
1313
* Gets all the pyenv environments.
@@ -33,6 +33,7 @@ async function* getPyenvEnvironments(): AsyncIterableIterator<BasicEnvInfo> {
3333
}
3434
}
3535
}
36+
traceVerbose('Finished searching for pyenv environments');
3637
}
3738

3839
export class PyenvLocator extends FSWatchingLocator {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { Locators } from '../../locators';
1616
import { getEnvs } from '../../locatorUtils';
1717
import { PythonEnvsChangedEvent } from '../../watcher';
1818
import { DirFilesLocator } from './filesLocator';
19+
import { traceVerbose } from '../../../../logging';
1920

2021
/**
2122
* A locator for Windows locators found under the $PATH env var.
@@ -93,6 +94,7 @@ function getDirFilesLocator(
9394
// take a naive approach.
9495
async function* iterEnvs(query: PythonLocatorQuery): IPythonEnvsIterator<BasicEnvInfo> {
9596
yield* await getEnvs(locator.iterEnvs(query));
97+
traceVerbose('Finished searching for windows path interpreters');
9698
}
9799
return {
98100
providerId: locator.providerId,

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import { PythonEnvKind, PythonEnvSource } from '../../info';
66
import { BasicEnvInfo, IPythonEnvsIterator, Locator } from '../../locator';
77
import { getRegistryInterpreters } from '../../../common/windowsUtils';
8-
import { traceError } from '../../../../logging';
8+
import { traceError, traceVerbose } from '../../../../logging';
99
import { isMicrosoftStoreDir } from '../../../common/environmentManagers/microsoftStoreEnv';
1010

1111
export class WindowsRegistryLocator extends Locator<BasicEnvInfo> {
@@ -33,6 +33,7 @@ export class WindowsRegistryLocator extends Locator<BasicEnvInfo> {
3333
traceError(`Failed to process environment: ${interpreter}`, ex);
3434
}
3535
}
36+
traceVerbose('Finished searching for windows registry interpreters');
3637
};
3738
return iterator();
3839
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ export class WorkspaceVirtualEnvironmentLocator extends FSWatchingLocator {
9797
});
9898

9999
yield* iterable(chain(envGenerators));
100+
traceVerbose(`Finished searching for workspace virtual envs`);
100101
}
101102

102103
return iterator(this.root);

src/client/pythonEnvironments/base/locators/lowLevel/macDefaultLocator.ts renamed to src/client/pythonEnvironments/common/environmentManagers/macDefault.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4-
import { getOSType, OSType } from '../../../../common/utils/platform';
5-
6-
// TODO: Add tests for 'isMacDefaultPythonPath' when working on the locator
4+
import { getOSType, OSType } from '../../../common/utils/platform';
75

86
/**
97
* Decide if the given Python executable looks like the MacOS default Python.

src/client/pythonEnvironments/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import {
3636
import { EnvsCollectionService } from './base/locators/composite/envsCollectionService';
3737
import { IDisposable } from '../common/types';
3838
import { traceError } from '../logging';
39-
import { ActiveStateLocator } from './base/locators/lowLevel/activestateLocator';
39+
import { ActiveStateLocator } from './base/locators/lowLevel/activeStateLocator';
4040

4141
/**
4242
* Set up the Python environments component (during extension activation).'

src/client/pythonEnvironments/legacyIOC.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { IComponentAdapter, ICondaService, PythonEnvironmentsChangedEvent } from
1010
import { IServiceManager } from '../ioc/types';
1111
import { PythonEnvInfo, PythonEnvKind, PythonEnvSource } from './base/info';
1212
import { IDiscoveryAPI, PythonLocatorQuery, TriggerRefreshOptions } from './base/locator';
13-
import { isMacDefaultPythonPath } from './base/locators/lowLevel/macDefaultLocator';
13+
import { isMacDefaultPythonPath } from './common/environmentManagers/macDefault';
1414
import { isParentPath } from './common/externalDependencies';
1515
import { EnvironmentType, PythonEnvironment } from './info';
1616
import { toSemverLikeVersion } from './base/info/pythonVersion';

src/test/pythonEnvironments/base/locators/lowLevel/activestateLocator.unit.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import * as fsapi from 'fs-extra';
77
import { PythonEnvKind } from '../../../../../client/pythonEnvironments/base/info';
88
import * as externalDependencies from '../../../../../client/pythonEnvironments/common/externalDependencies';
99
import { getEnvs } from '../../../../../client/pythonEnvironments/base/locatorUtils';
10-
import { ActiveStateLocator } from '../../../../../client/pythonEnvironments/base/locators/lowLevel/activestateLocator';
10+
import { ActiveStateLocator } from '../../../../../client/pythonEnvironments/base/locators/lowLevel/activeStateLocator';
1111
import { TEST_LAYOUT_ROOT } from '../../../common/commonTestConstants';
1212
import { assertBasicEnvsEqual } from '../envTestUtils';
1313
import { ExecutionResult } from '../../../../../client/common/process/types';

src/test/pythonEnvironments/base/locators/lowLevel/macDefaultLocator.unit.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import * as assert from 'assert';
55
import * as sinon from 'sinon';
66
import * as osUtils from '../../../../../client/common/utils/platform';
7-
import { isMacDefaultPythonPath } from '../../../../../client/pythonEnvironments/base/locators/lowLevel/macDefaultLocator';
7+
import { isMacDefaultPythonPath } from '../../../../../client/pythonEnvironments/common/environmentManagers/macDefault';
88

99
suite('isMacDefaultPythonPath', () => {
1010
let getOSTypeStub: sinon.SinonStub;

src/test/pythonEnvironments/base/locators/lowLevel/posixKnownPathsLocator.unit.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { PosixKnownPathsLocator } from '../../../../../client/pythonEnvironments
1414
import { createBasicEnv } from '../../common';
1515
import { TEST_LAYOUT_ROOT } from '../../../common/commonTestConstants';
1616
import { assertBasicEnvsEqual } from '../envTestUtils';
17-
import { isMacDefaultPythonPath } from '../../../../../client/pythonEnvironments/base/locators/lowLevel/macDefaultLocator';
17+
import { isMacDefaultPythonPath } from '../../../../../client/pythonEnvironments/common/environmentManagers/macDefault';
1818

1919
suite('Posix Known Path Locator', () => {
2020
let getPathEnvVar: sinon.SinonStub;

0 commit comments

Comments
 (0)