]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-109565: Fix concurrent.futures test_future_times_out() (GH-109949) (#109952)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 2 Oct 2023 15:40:16 +0000 (08:40 -0700)
committerGitHub <noreply@github.com>
Mon, 2 Oct 2023 15:40:16 +0000 (17:40 +0200)
gh-109565: Fix concurrent.futures test_future_times_out() (GH-109949)

as_completed() uses a timeout of 100 ms instead of 10 ms. Windows
monotonic clock resolution is around 15.6 ms.
(cherry picked from commit b1aebf1e6576680d606068d17e2208259573e061)

Co-authored-by: Victor Stinner <vstinner@python.org>
Lib/test/test_concurrent_futures/test_as_completed.py

index 2b3bec8cafbcb05d22efec8467b1ffdabd8823ad..c90b0021d85fc7db7a56db073fd2b58bba376ea1 100644 (file)
@@ -42,11 +42,14 @@ class AsCompletedTests:
                              EXCEPTION_FUTURE,
                              SUCCESSFUL_FUTURE}
 
-        for timeout in (0, 0.01):
+        # Windows clock resolution is around 15.6 ms
+        short_timeout = 0.100
+        for timeout in (0, short_timeout):
             with self.subTest(timeout):
 
-                future = self.executor.submit(time.sleep, 0.1)
                 completed_futures = set()
+                future = self.executor.submit(time.sleep, short_timeout * 10)
+
                 try:
                     for f in futures.as_completed(
                         already_completed | {future},