Skip to content

Commit

Permalink
Add customizable interpreter discovery timeout (#24227)
Browse files Browse the repository at this point in the history
Addressing issue #24226

This adds a way to customize the timeout for the interpreter info script
to run, by customizing the duration of the
`VSC_PYTHON_INTERPRETER_INFO_TIMEOUT` environment variable.

This is to address setups (e.g. a monorepo with Bazel) where the hard
coded 15 seconds is insufficient, as the first Python run also includes
additional setup work to ensure the venv is available for use before the
interpreter can actually execute.

This is being done via env var instead of via a VS Code setting to avoid
introducing additional settings that will be deprecated after other
planned upcoming work on interpreter discovery (see discussion on
24226).
  • Loading branch information
mnoah1 authored Oct 7, 2024
1 parent ebe55a4 commit 204b8ca
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/client/pythonEnvironments/base/info/interpreter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
InterpreterInfoJson,
} from '../../../common/process/internal/scripts';
import { Architecture } from '../../../common/utils/platform';
import { traceError, traceVerbose } from '../../../logging';
import { traceError, traceInfo, traceVerbose } from '../../../logging';
import { shellExecute } from '../../common/externalDependencies';
import { copyPythonExecInfo, PythonExecInfo } from '../../exec';
import { parseVersion } from './pythonVersion';
Expand Down Expand Up @@ -82,7 +82,13 @@ 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;
let standardTimeout = isCI ? 30000 : 15000;
if (process.env.VSC_PYTHON_INTERPRETER_INFO_TIMEOUT !== undefined) {
// Custom override for setups where the initial Python setup process may take longer than the standard timeout.
standardTimeout = parseInt(process.env.VSC_PYTHON_INTERPRETER_INFO_TIMEOUT, 10);
traceInfo(`Custom interpreter discovery timeout: ${standardTimeout}`);
}

// 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.
Expand Down

0 comments on commit 204b8ca

Please sign in to comment.