Skip to content

Commit

Permalink
Add extra logging regarding interpreter discovery (#21639)
Browse files Browse the repository at this point in the history
For #21310
  • Loading branch information
Kartik Raj committed Jul 17, 2023
1 parent fc1c391 commit 2e8dc67
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/client/common/process/rawProcessApis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export function plainExec(
const deferred = createDeferred<ExecutionResult<string>>();
const disposable: IDisposable = {
dispose: () => {
if (!proc.killed && !deferred.completed) {
if (!proc.killed) {
proc.kill();
}
},
Expand Down Expand Up @@ -156,10 +156,12 @@ export function plainExec(
deferred.resolve({ stdout, stderr });
}
internalDisposables.forEach((d) => d.dispose());
disposable.dispose();
});
proc.once('error', (ex) => {
deferred.reject(ex);
internalDisposables.forEach((d) => d.dispose());
disposable.dispose();
});

return deferred.promise;
Expand Down
6 changes: 6 additions & 0 deletions src/client/common/utils/async.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,17 @@ class DeferredImpl<T> implements Deferred<T> {
}

public resolve(_value: T | PromiseLike<T>) {
if (this.completed) {
return;
}
this._resolve.apply(this.scope ? this.scope : this, [_value]);
this._resolved = true;
}

public reject(_reason?: string | Error | Record<string, unknown>) {
if (this.completed) {
return;
}
this._reject.apply(this.scope ? this.scope : this, [_reason]);
this._rejected = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export class ActiveStateLocator extends LazyResourceBasedLocator {
traceVerbose(`Couldn't locate the state binary.`);
return;
}
traceVerbose(`Searching for active state environments`);
const projects = await state.getProjects();
if (projects === undefined) {
traceVerbose(`Couldn't fetch State Tool projects.`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export class MicrosoftStoreLocator extends FSWatchingLocator {

protected doIterEnvs(): IPythonEnvsIterator<BasicEnvInfo> {
const iterator = async function* (kind: PythonEnvKind) {
traceVerbose('Searching for windows store envs');
const exes = await getMicrosoftStorePythonExes();
yield* exes.map(async (executablePath: string) => ({
kind,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export class PosixKnownPathsLocator extends Locator<BasicEnvInfo> {
}

const iterator = async function* (kind: PythonEnvKind) {
traceVerbose('Searching for interpreters in posix paths locator');
// Filter out pyenv shims. They are not actual python binaries, they are used to launch
// the binaries specified in .python-version file in the cwd. We should not be reporting
// those binaries as environments.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { traceError, traceVerbose } from '../../../../logging';
* all the environments (global or virtual) in that directory.
*/
async function* getPyenvEnvironments(): AsyncIterableIterator<BasicEnvInfo> {
traceVerbose('Searching for pyenv environments');
const pyenvVersionDir = getPyenvVersionsDir();

const subDirs = getSubDirs(pyenvVersionDir, { resolveSymlinks: true });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ function getDirFilesLocator(
// rather than in each low-level locator. In the meantime we
// take a naive approach.
async function* iterEnvs(query: PythonLocatorQuery): IPythonEnvsIterator<BasicEnvInfo> {
traceVerbose('Searching for windows path interpreters');
yield* await getEnvs(locator.iterEnvs(query));
traceVerbose('Finished searching for windows path interpreters');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export class WindowsRegistryLocator extends Locator<BasicEnvInfo> {
// eslint-disable-next-line class-methods-use-this
public iterEnvs(): IPythonEnvsIterator<BasicEnvInfo> {
const iterator = async function* () {
traceVerbose('Searching for windows registry interpreters');
const interpreters = await getRegistryInterpreters();
for (const interpreter of interpreters) {
try {
Expand Down

0 comments on commit 2e8dc67

Please sign in to comment.