Skip to content

Commit bcdb0e2

Browse files
authored
Fix timeout handling for zero-millisecond values
Previously, when `timeout_ms` was explicitly set to `0`, the condition `if args.timeout_ms` evaluated to `False` (since `0` is falsy), causing the timeout to be treated as `None` (no timeout). This violated the intended behavior where `0` should mean "time out immediately." The fix changes the check to `if args.timeout_ms is not None`, ensuring that: - `timeout_ms=0` correctly results in a `0.0` second timeout - `timeout_ms=None` (or unset) still results in no timeout - All other positive values work as before This aligns the implementation with standard `subprocess.run()` timeout semantics and prevents unintended indefinite command execution.
1 parent cfddc7c commit bcdb0e2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

examples/tools/local_shell.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def shell_executor(request: LocalShellCommandRequest) -> str:
1515
env={**os.environ, **args.env} if args.env else os.environ,
1616
capture_output=True,
1717
text=True,
18-
timeout=(args.timeout_ms / 1000) if args.timeout_ms else None,
18+
timeout=(args.timeout_ms / 1000) if args.timeout_ms is not None else None,
1919
)
2020
return completed.stdout + completed.stderr
2121

0 commit comments

Comments
 (0)