gh-133089: Use original timeout value for TimeoutExpired when the func subprocess.run is called with a timeout (GH-133103)

Signed-off-by: Manjusaka <me@manjusaka.me>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
This commit is contained in:
Nadeshiko Manju 2025-05-05 09:15:31 +08:00 committed by GitHub
parent 51d2459e4d
commit 2bbcaedb75
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 46 additions and 4 deletions

View file

@ -1525,6 +1525,24 @@ handling consistency are valid for these functions.
Notes
-----
.. _subprocess-timeout-behavior:
Timeout Behavior
^^^^^^^^^^^^^^^^
When using the ``timeout`` parameter in functions like :func:`run`,
:meth:`Popen.wait`, or :meth:`Popen.communicate`,
users should be aware of the following behaviors:
1. **Process Creation Delay**: The initial process creation itself cannot be interrupted
on many platform APIs. This means that even when specifying a timeout, you are not
guaranteed to see a timeout exception until at least after however long process
creation takes.
2. **Extremely Small Timeout Values**: Setting very small timeout values (such as a few
milliseconds) may result in almost immediate :exc:`TimeoutExpired` exceptions because
process creation and system scheduling inherently require time.
.. _converting-argument-sequence:
Converting an argument sequence to a string on Windows