Skip to content

Commit 044b66d

Browse files
committed
feat: add manager ready timeout setting (exp)
1 parent 8e3904b commit 044b66d

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

package.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,15 @@
135135
"description": "%python-envs.alwaysUseUv.description%",
136136
"default": true,
137137
"scope": "machine"
138+
},
139+
"python-envs.experimental.managerReadyTimeout": {
140+
"type": "integer",
141+
"default": 15,
142+
"minimum": 5,
143+
"maximum": 120,
144+
"markdownDescription": "%python-envs.experimental.managerReadyTimeout.description%",
145+
"scope": "machine",
146+
"tags": ["experimental"]
138147
}
139148
}
140149
},

package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"python-envs.terminal.useEnvFile.description": "Controls whether environment variables from .env files and python.envFile setting are injected into terminals.",
1414
"python-envs.globalSearchPaths.description": "Absolute paths to search for Python environments across all workspaces. Use for shared environment folders like `~/envs`.",
1515
"python-envs.workspaceSearchPaths.description": "Paths to search for environments in this workspace. By default, searches for a `.venv` folder in the workspace root.",
16+
"python-envs.experimental.managerReadyTimeout.description": "(Experimental) Timeout in seconds before giving up on waiting for an environment manager to register. Increase if you use slow or remote filesystems. Default: 15.",
1617
"python-envs.terminal.revertStartupScriptChanges.title": "Revert Shell Startup Script Changes",
1718
"python-envs.reportIssue.title": "Report Issue",
1819
"python-envs.setEnvManager.title": "Set Environment Manager",

src/features/common/managerReady.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,20 @@ import { sendTelemetryEvent } from '../../common/telemetry/sender';
77
import { createDeferred, Deferred } from '../../common/utils/deferred';
88
import { showErrorMessage } from '../../common/window.apis';
99
import { installExtension } from '../../common/workbenchCommands';
10+
import { getConfiguration } from '../../common/workspace.apis';
1011
import { EnvironmentManagers, PythonProjectManager } from '../../internal.api';
1112
import { getDefaultEnvManagerSetting, getDefaultPkgManagerSetting } from '../settings/settingHelpers';
1213

13-
const MANAGER_READY_TIMEOUT_MS = 30_000;
14+
const DEFAULT_MANAGER_READY_TIMEOUT_MS = 15_000;
15+
16+
function getManagerReadyTimeoutMs(): number {
17+
const config = getConfiguration('python-envs');
18+
const userValue = config.get<number>('experimental.managerReadyTimeout');
19+
if (typeof userValue === 'number' && userValue >= 5 && userValue <= 120) {
20+
return userValue * 1000;
21+
}
22+
return DEFAULT_MANAGER_READY_TIMEOUT_MS;
23+
}
1424

1525
interface ManagerReady extends Disposable {
1626
waitForEnvManager(uris?: Uri[]): Promise<void>;
@@ -120,21 +130,24 @@ class ManagerReadyImpl implements ManagerReady {
120130
if (deferred.completed) {
121131
return deferred.promise;
122132
}
133+
const timeoutMs = getManagerReadyTimeoutMs();
123134
return new Promise<void>((resolve) => {
124135
const timer = setTimeout(() => {
125136
if (!deferred.completed) {
126137
traceWarn(
127-
`Timed out after ${MANAGER_READY_TIMEOUT_MS / 1000}s waiting for ${kind} manager "${managerId}" to register. ` +
138+
`Timed out after ${timeoutMs / 1000}s waiting for ${kind} manager "${managerId}" to register. ` +
128139
`The manager may not be installed or its extension failed to activate. Proceeding without it. ` +
129-
`To prevent this, check your "python-envs.defaultEnvManager" and "python-envs.pythonProjects" settings.`,
140+
`To prevent this, check your "python-envs.defaultEnvManager" and "python-envs.pythonProjects" settings. ` +
141+
`If the manager is slow to start (e.g. on a remote or network filesystem), increase the timeout via ` +
142+
`"python-envs.experimental.managerReadyTimeout" (current: ${timeoutMs / 1000}s, range: 5–120s).`,
130143
);
131144
sendTelemetryEvent(EventNames.MANAGER_READY_TIMEOUT, undefined, {
132145
managerId,
133146
managerKind: kind as 'environment' | 'package',
134147
});
135148
deferred.resolve();
136149
}
137-
}, MANAGER_READY_TIMEOUT_MS);
150+
}, timeoutMs);
138151

139152
deferred.promise.then(
140153
() => {

0 commit comments

Comments
 (0)