cpython/Misc
Miss Islington (bot) 12471131a7
[3.13] gh-87512: Fix subprocess using timeout= on Windows blocking with a large input= (GH-142058) (#142069)
gh-87512: Fix `subprocess` using `timeout=` on Windows blocking with a large `input=` (GH-142058)

On Windows, Popen._communicate() previously wrote to stdin synchronously, which could block indefinitely if the subprocess didn't consume input= quickly and the pipe buffer filled up. The timeout= parameter was only checked when joining the reader threads, not during the stdin write.

This change moves the Windows stdin writing to a background thread (similar to how stdout/stderr are read in threads), allowing the timeout to be properly enforced. If timeout expires, TimeoutExpired is raised promptly and the writer thread continues in the background. Subsequent calls to communicate() will join the existing writer thread.

Adds test_communicate_timeout_large_input to verify that TimeoutExpired is raised promptly when communicate() is called with large input and a timeout, even when the subprocess doesn't consume stdin quickly.

This test already passed on POSIX (where select() is used) but failed on Windows where the stdin write blocks without checking the timeout.
(cherry picked from commit 5b1862bdd8)

Co-authored-by: Gregory P. Smith <68491+gpshead@users.noreply.github.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2025-11-29 07:22:46 +00:00
..
mypy [3.13] gh-133117: Run mypy on tomllib in CI (GH-133118) (#133192) 2025-04-30 12:57:57 +00:00
NEWS.d [3.13] gh-87512: Fix subprocess using timeout= on Windows blocking with a large input= (GH-142058) (#142069) 2025-11-29 07:22:46 +00:00
rhel7 gh-95957: Add instructions for Tcl/Tk and OpenSSL on RHEL/CentOS 7 (#95964) 2022-08-16 13:44:02 +02:00
ACKS [3.13] gh-134759: fix UnboundLocalError in email.message.Message.get_payload (GH-136071) (#136580) 2025-07-12 13:52:54 +00:00
coverity_model.c [3.13] Fix typos (#123775) (#123866) 2024-10-07 23:44:31 +02:00
externals.spdx.json [3.13] gh-139573: Update Windows builds to use OpenSSL 3.0.18 (GH-139587) 2025-10-04 20:53:16 -05:00
HISTORY [3.13] gh-123492: Remove unnecessary :func: parentheses (gh-123493) (#123513) 2024-08-30 20:14:48 +03:00
indent.pro
platform_triplet.c [3.13] gh-132026: Ensure _MIPS_SIM has defined _ABI identifiers for comparison (GH-133092) 2025-04-28 12:15:45 -05:00
Porting bpo-30737: Update DevGuide links to new URL (GH-3228) 2017-08-30 09:37:43 -07:00
python-config.in bpo-45101: Add consistency in usage message IO between 2 versions of python-config (GH-28162) 2024-02-26 22:04:44 +02:00
python-config.sh.in [3.13] gh-116622: Rename build variable MODULE_LDFLAGS back to LIBPYTHON (GH-122764) (GH-122842) 2024-08-09 14:45:04 -07:00
python-embed.pc.in bpo-36721: Add --embed option to python-config (GH-13500) 2019-05-23 03:30:23 +02:00
python.man [3.13] Manpage: -X gil is not related to PYTHON_HISTORY (GH-133753) (#133759) 2025-05-09 14:18:56 +00:00
python.pc.in [3.13] gh-116622: Rename build variable MODULE_LDFLAGS back to LIBPYTHON (GH-122764) (GH-122842) 2024-08-09 14:45:04 -07:00
README gh-102809: Remove gdbinit mention in Misc/README (#103269) 2023-04-08 00:04:23 -07:00
README.AIX bpo-42087: Remove support for AIX 5.3 and below (GH-22830) 2020-11-16 16:16:10 +01:00
README.coverity
README.valgrind closes docs: remove references to Py_USING_MEMORY_DEBUGGER (GH-30284) 2021-12-29 16:20:42 -06:00
sbom.spdx.json [3.13] gh-139312: Update bundled libexpat to 2.7.3 (GH-139319) (#139377) 2025-09-27 08:19:09 +00:00
SpecialBuilds.txt gh-108634: Py_TRACE_REFS uses a hash table (#108663) 2023-08-31 18:33:34 +02:00
stable_abi.toml [3.13] gh-141909: Add PyModuleDef_Slot and earlier Py_mod_* constants to stable ABI manifest (#141910) (GH-141977) 2025-11-26 15:34:57 +01:00
svnmap.txt bpo-32159: Revert Misc/svnmap.txt (#4639) 2017-11-29 18:58:33 +01:00
valgrind-python.supp [3.13] gh-121096: Ignore dlopen() leaks in Valgrind suppression file (GH-121097) (#121122) 2024-06-28 11:26:37 +00:00
vgrindefs

Python Misc subdirectory
========================

This directory contains files that wouldn't fit in elsewhere.  Some
documents are only of historic importance.

Files found here
----------------

ACKS                    Acknowledgements
HISTORY                 News from previous releases -- oldest last
indent.pro              GNU indent profile approximating my C style
NEWS                    News for this release (for some meaning of "this")
Porting                 Mini-FAQ on porting to new platforms
python-config.in        Python script template for python-config
python.man              UNIX man page for the python interpreter
python.pc.in            Package configuration info template for pkg-config
README                  The file you're reading now
README.AIX              Information about using Python on AIX
README.coverity         Information about running Coverity's Prevent on Python
README.valgrind         Information for Valgrind users, see valgrind-python.supp
SpecialBuilds.txt       Describes extra symbols you can set for debug builds
svnmap.txt              Map of old SVN revs and branches to hg changeset ids,
                        help history-digging
valgrind-python.supp    Valgrind suppression file, see README.valgrind
vgrindefs               Python configuration for vgrind (a generic pretty printer)