Skip to content

Negative run-time reported by subprocess.run's TimeoutExpired exception when setting timeout=0 #133089

Closed
@vadimkantorov

Description

@vadimkantorov

Bug report

Bug description:

import subprocess
subprocess.run(['echo', 'hi'], timeout = 0)

# subprocess.TimeoutExpired: Command '['echo', 'hi']' timed out after -0.00010189996100962162 seconds
# subprocess.TimeoutExpired: Command '['echo', 'hi']' timed out after -4.819990135729313e-05 seconds

This is quite unexpected that the measured run-time can be negative

In general, it's unclear in the docs what behavior should have timeout=0. I would propose that it should disable timeout control, and should be equivalent to timeout=None.

But in any case, negative run-times are quite strange :)

CPython versions tested on:

3.12

Operating systems tested on:

WSLv1+Ubuntu24.04

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13bugs and security fixes3.14new features, bugs and security fixesstdlibPython modules in the Lib dirtopic-subprocessSubprocess issues.type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions