Skip to content

Commit 15af5ba

Browse files
committed
Update Python interpreter discovery timeout
1 parent 7d01dc2 commit 15af5ba

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,12 @@
560560
"scope": "machine",
561561
"type": "string"
562562
},
563+
"python.interpreter.getInfoTimeout": {
564+
"default": 15000,
565+
"description": "%python.interpreter.getInfoTimeout.description%",
566+
"scope": "resource",
567+
"type": "number"
568+
},
563569
"python.logging.level": {
564570
"default": "error",
565571
"deprecationMessage": "%python.logging.level.deprecation%",

package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"python.interpreter.infoVisibility.never.description": "Never display information.",
5757
"python.interpreter.infoVisibility.onPythonRelated.description": "Only display information if Python-related files are opened.",
5858
"python.interpreter.infoVisibility.always.description": "Always display information.",
59+
"python.interpreter.getInfoTimeout.description": "Timeout (ms) to use while running interpreter discovery script.",
5960
"python.logging.level.description": "The logging level the extension logs at, defaults to 'error'",
6061
"python.logging.level.deprecation": "This setting is deprecated. Please use command `Developer: Set Log Level...` to set logging level.",
6162
"python.missingPackage.severity.description": "Set severity of missing packages in requirements.txt or pyproject.toml",

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
InterpreterInfoJson,
99
} from '../../../common/process/internal/scripts';
1010
import { Architecture } from '../../../common/utils/platform';
11+
import { getConfiguration } from '../../../common/vscodeApis/workspaceApis';
1112
import { traceError, traceVerbose } from '../../../logging';
1213
import { shellExecute } from '../../common/externalDependencies';
1314
import { copyPythonExecInfo, PythonExecInfo } from '../../exec';
@@ -82,7 +83,8 @@ export async function getInterpreterInfo(
8283
);
8384

8485
// 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;
86+
const standardTimeout = isCI ? 30000 : getConfiguration('python').get<number>("interpreter.getInfoTimeout");
87+
8688
// Try shell execing the command, followed by the arguments. This will make node kill the process if it
8789
// takes too long.
8890
// Sometimes the python path isn't valid, timeout if that's the case.

src/test/pythonEnvironments/base/locators/composite/envsResolver.unit.test.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import { assert, expect } from 'chai';
55
import { cloneDeep } from 'lodash';
66
import * as path from 'path';
77
import * as sinon from 'sinon';
8-
import { EventEmitter, Uri } from 'vscode';
8+
import * as typemoq from 'typemoq';
9+
import { ConfigurationScope, EventEmitter, Uri, WorkspaceConfiguration } from 'vscode';
910
import { ExecutionResult } from '../../../../../client/common/process/types';
1011
import { IDisposableRegistry } from '../../../../../client/common/types';
1112
import { Architecture } from '../../../../../client/common/utils/platform';
@@ -44,14 +45,27 @@ suite('Python envs locator - Environments Resolver', () => {
4445
let envInfoService: IEnvironmentInfoService;
4546
let disposables: IDisposableRegistry;
4647
const testVirtualHomeDir = path.join(TEST_LAYOUT_ROOT, 'virtualhome');
48+
let getConfigurationStub: sinon.SinonStub;
49+
let configMock: typemoq.IMock<WorkspaceConfiguration>;
4750

4851
setup(() => {
4952
disposables = [];
5053
envInfoService = getEnvironmentInfoService(disposables);
54+
configMock = typemoq.Mock.ofType<WorkspaceConfiguration>();
55+
getConfigurationStub = sinon.stub(workspaceApis, 'getConfiguration');
56+
getConfigurationStub.callsFake((section?: string, _scope?: ConfigurationScope | null) => {
57+
if (section === 'python') {
58+
return configMock.object;
59+
}
60+
return undefined;
61+
});
62+
configMock.setup((c) => c.get<number>('interpreter.getInfoTimeout')).returns(() => 15000);
5163
});
5264
teardown(() => {
5365
sinon.restore();
5466
disposables.forEach((d) => d.dispose());
67+
getConfigurationStub.restore();
68+
configMock.reset();
5569
});
5670

5771
/**

0 commit comments

Comments
 (0)