Skip to content

Commit 204b8ca

Browse files
authored
Add customizable interpreter discovery timeout (#24227)
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).
1 parent ebe55a4 commit 204b8ca

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/client/pythonEnvironments/base/info/interpreter.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
InterpreterInfoJson,
99
} from '../../../common/process/internal/scripts';
1010
import { Architecture } from '../../../common/utils/platform';
11-
import { traceError, traceVerbose } from '../../../logging';
11+
import { traceError, traceInfo, traceVerbose } from '../../../logging';
1212
import { shellExecute } from '../../common/externalDependencies';
1313
import { copyPythonExecInfo, PythonExecInfo } from '../../exec';
1414
import { parseVersion } from './pythonVersion';
@@ -82,7 +82,13 @@ export async function getInterpreterInfo(
8282
);
8383

8484
// Sometimes on CI, the python process takes a long time to start up. This is a workaround for that.
85-
const standardTimeout = isCI ? 30000 : 15000;
85+
let standardTimeout = isCI ? 30000 : 15000;
86+
if (process.env.VSC_PYTHON_INTERPRETER_INFO_TIMEOUT !== undefined) {
87+
// Custom override for setups where the initial Python setup process may take longer than the standard timeout.
88+
standardTimeout = parseInt(process.env.VSC_PYTHON_INTERPRETER_INFO_TIMEOUT, 10);
89+
traceInfo(`Custom interpreter discovery timeout: ${standardTimeout}`);
90+
}
91+
8692
// Try shell execing the command, followed by the arguments. This will make node kill the process if it
8793
// takes too long.
8894
// Sometimes the python path isn't valid, timeout if that's the case.

0 commit comments

Comments
 (0)