Skip to content

Commit 07c6fd7

Browse files
fix: add timeout to streaming subprocess.run() in base.py dispatch_command
The streaming branch of dispatch_command() called subprocess.run() without a timeout, which could hang indefinitely if the child process stalls. Now uses the same timeout parameter (default 600s) as the non-streaming branch, with proper TimeoutExpired handling.
1 parent f8b3d60 commit 07c6fd7

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

  • src/specify_cli/integrations

src/specify_cli/integrations/base.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,15 +386,22 @@ def dispatch_command(
386386
cwd = str(project_root) if project_root else None
387387

388388
if stream:
389-
# No timeout when streaming — the user sees live output and
390-
# can Ctrl+C at any time. The timeout parameter is only
391-
# applied in the captured (non-streaming) branch below.
389+
# Stream output directly to the terminal so the user sees live
390+
# progress. Apply the same timeout as the captured branch to
391+
# prevent indefinite hangs if the child process stalls.
392392
try:
393393
result = subprocess.run(
394394
exec_args,
395395
text=True,
396396
cwd=cwd,
397+
timeout=timeout,
397398
)
399+
except subprocess.TimeoutExpired:
400+
return {
401+
"exit_code": 124,
402+
"stdout": "",
403+
"stderr": f"Command timed out after {timeout}s",
404+
}
398405
except KeyboardInterrupt:
399406
return {
400407
"exit_code": 130,

0 commit comments

Comments
 (0)