Skip to content

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

analysis/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ requires = ["uv_build>=0.10.2,<0.11.0"]
33
build-backend = "uv_build"
44

55
[tool.uv.build-backend]
6-
module-root = ""
6+
module-root = ".."
77

88
[project]
99
name = "analysis"

src/managers/builtin/helpers.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,15 @@ export async function runUV(
6464
cwd?: string,
6565
log?: LogOutputChannel,
6666
token?: CancellationToken,
67+
timeout?: number,
6768
): Promise<string> {
6869
log?.info(`Running: uv ${args.join(' ')}`);
6970
return new Promise<string>((resolve, reject) => {
70-
const proc = spawnProcess('uv', args, { cwd: cwd });
71+
const spawnOptions: { cwd?: string; timeout?: number } = { cwd };
72+
if (timeout !== undefined) {
73+
spawnOptions.timeout = timeout;
74+
}
75+
const proc = spawnProcess('uv', args, spawnOptions);
7176
token?.onCancellationRequested(() => {
7277
proc.kill();
7378
reject(new CancellationError());
@@ -104,10 +109,11 @@ export async function runPython(
104109
cwd?: string,
105110
log?: LogOutputChannel,
106111
token?: CancellationToken,
112+
timeout?: number,
107113
): Promise<string> {
108114
log?.info(`Running: ${python} ${args.join(' ')}`);
109115
return new Promise<string>((resolve, reject) => {
110-
const proc = spawnProcess(python, args, { cwd: cwd });
116+
const proc = spawnProcess(python, args, { cwd: cwd, timeout });
111117
token?.onCancellationRequested(() => {
112118
proc.kill();
113119
reject(new CancellationError());

src/managers/builtin/utils.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,29 @@ export async function refreshPythons(
139139
return sortEnvironments(collection);
140140
}
141141

142+
const PIP_LIST_TIMEOUT_MS = 30_000;
143+
142144
async function refreshPipPackagesRaw(environment: PythonEnvironment, log?: LogOutputChannel): Promise<string> {
143145
// Use environmentPath directly for consistency with UV environment tracking
144146
const useUv = await shouldUseUv(log, environment.environmentPath.fsPath);
145147
if (useUv) {
146-
return await runUV(['pip', 'list', '--python', environment.execInfo.run.executable], undefined, log);
148+
return await runUV(
149+
['pip', 'list', '--python', environment.execInfo.run.executable],
150+
undefined,
151+
log,
152+
undefined,
153+
PIP_LIST_TIMEOUT_MS,
154+
);
147155
}
148156
try {
149-
return await runPython(environment.execInfo.run.executable, ['-m', 'pip', 'list'], undefined, log);
157+
return await runPython(
158+
environment.execInfo.run.executable,
159+
['-m', 'pip', 'list'],
160+
undefined,
161+
log,
162+
undefined,
163+
PIP_LIST_TIMEOUT_MS,
164+
);
150165
} catch (ex) {
151166
log?.error('Error running pip list', ex);
152167
log?.info(

0 commit comments

Comments
 (0)