Skip to content

Commit

Permalink
Add verbose logging for change events fired related to envs (#20780)
Browse files Browse the repository at this point in the history
For #20292
  • Loading branch information
Kartik Raj authored Mar 1, 2023
1 parent be75eb2 commit 32c10e4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/client/proposedApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ export function buildProposedApi(
}
if (e.old) {
if (e.new) {
traceVerbose('Python API env change detected', env.id, 'update');
onEnvironmentsChanged.fire({ type: 'update', env: convertEnvInfoAndGetReference(e.new) });
reportInterpretersChanged([
{
Expand All @@ -157,6 +158,7 @@ export function buildProposedApi(
},
]);
} else {
traceVerbose('Python API env change detected', env.id, 'remove');
onEnvironmentsChanged.fire({ type: 'remove', env: convertEnvInfoAndGetReference(e.old) });
reportInterpretersChanged([
{
Expand All @@ -166,6 +168,7 @@ export function buildProposedApi(
]);
}
} else if (e.new) {
traceVerbose('Python API env change detected', env.id, 'add');
onEnvironmentsChanged.fire({ type: 'add', env: convertEnvInfoAndGetReference(e.new) });
reportInterpretersChanged([
{
Expand Down
5 changes: 4 additions & 1 deletion src/client/pythonEnvironments/base/info/interpreter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License.

import { PythonExecutableInfo, PythonVersion } from '.';
import { isCI } from '../../../common/constants';
import {
interpreterInfo as getInterpreterInfoCommand,
InterpreterInfoJson,
Expand Down Expand Up @@ -80,13 +81,15 @@ export async function getInterpreterInfo(
'',
);

// Sometimes on CI, the python process takes a long time to start up. This is a workaround for that.
const standardTimeout = isCI ? 30000 : 15000;
// Try shell execing the command, followed by the arguments. This will make node kill the process if it
// takes too long.
// Sometimes the python path isn't valid, timeout if that's the case.
// See these two bugs:
// https://github.com/microsoft/vscode-python/issues/7569
// https://github.com/microsoft/vscode-python/issues/7760
const result = await shellExecute(quoted, { timeout: timeout ?? 15000 });
const result = await shellExecute(quoted, { timeout: timeout ?? standardTimeout });
if (result.stderr) {
traceError(
`Stderr when executing script with >> ${quoted} << stderr: ${result.stderr}, still attempting to parse output`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export class PythonEnvInfoCache extends PythonEnvsWatcher<PythonEnvCollectionCha
.reverse(); // Reversed so indexes do not change when deleting
invalidIndexes.forEach((index) => {
const env = this.envs.splice(index, 1)[0];
traceVerbose(`Removing invalid env from cache ${env.id}`);
this.fire({ old: env, new: undefined });
});
if (envs) {
Expand Down

0 comments on commit 32c10e4

Please sign in to comment.