https://github.com/python/cpython/commit/58545345ba91356bac9fe75952f7fbcc376ee755
commit: 58545345ba91356bac9fe75952f7fbcc376ee755
branch: 3.13
author: Miss Islington (bot) <[email protected]>
committer: zware <[email protected]>
date: 2026-09-02T18:07:53Z
summary:

[3.13] gh-119452: test_large_content_length_truncated: Don't use the full 
LOOPBACK_TIMEOUT on Windows (GH-156851)

This is a follow-up to GH-155951 (commit 
39921ebf7007a7fe3181bbebcf64d4433ec5de7a)
(cherry picked from commit abab65540c164efc4bde04c0bb690473c625ed4f)

Co-authored-by: Petr Viktorin <[email protected]>

files:
M Lib/test/test_httpservers.py

diff --git a/Lib/test/test_httpservers.py b/Lib/test/test_httpservers.py
index 2918e51ffadd30..0132d73c6fe230 100644
--- a/Lib/test/test_httpservers.py
+++ b/Lib/test/test_httpservers.py
@@ -1023,7 +1023,16 @@ def test_large_content_length(self):
             self.assertEqual(res.read(), b'%d %d' % (size, size) + 
self.linesep)
 
     def test_large_content_length_truncated(self):
-        with support.swap_attr(self.request_handler, 'timeout', 
support.LOOPBACK_TIMEOUT):
+        timeout = support.LOOPBACK_TIMEOUT
+        if not hasattr(os, 'fork'):
+            # On Windows, request() waits for the entire timeout; the default
+            # LOOPBACK_TIMEOUT (10s) is too long for 40 repetitions.
+            # Use a fraction of that (for slow machines), or .001 (in case
+            # LOOPBACK_TIMEOUT is configured to be smaller).
+            timeout = max(timeout / 100, 0.001)
+            # (On Unix, request() returns early so a large LOOPBACK_TIMEOUT
+            # isn't an issue.)
+        with support.swap_attr(self.request_handler, 'timeout', timeout):
             for w in range(18, 65):
                 size = 1 << w
                 headers = {'Content-Length' : str(size)}

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to