summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2023-10-02 15:42:03 (GMT)
committerGitHub <noreply@github.com>2023-10-02 15:42:03 (GMT)
commit9cf6d89165ac5543c5c2a3112f303f32778c2548 (patch)
tree27af1f5c51401db3e12bd5b168530364417f5ad8
parent9be6a111993c5e75574b0e858b57969c245c5866 (diff)
downloadcpython-9cf6d89165ac5543c5c2a3112f303f32778c2548.zip
cpython-9cf6d89165ac5543c5c2a3112f303f32778c2548.tar.gz
cpython-9cf6d89165ac5543c5c2a3112f303f32778c2548.tar.bz2
[3.12] gh-109594: Fix concurrent.futures test_timeout() (GH-110018) (#110021)
gh-109594: Fix concurrent.futures test_timeout() (GH-110018) Fix test_timeout() of test_concurrent_futures.test_wait. Remove the future which may or may not complete depending if it takes longer than the timeout ot not. Keep the second future which does not complete before wait(). Make also the test faster: 0.5 second instead of 6 seconds, so remove @support.requires_resource('walltime') decorator. (cherry picked from commit 9be283e5e15d5d5685b78a38eb132501f7f3febb) Co-authored-by: Victor Stinner <vstinner@python.org>
-rw-r--r--Lib/test/test_concurrent_futures/test_wait.py17
-rw-r--r--Misc/NEWS.d/next/Tests/2023-09-28-14-47-14.gh-issue-109594.DB5KPP.rst4
2 files changed, 13 insertions, 8 deletions
diff --git a/Lib/test/test_concurrent_futures/test_wait.py b/Lib/test/test_concurrent_futures/test_wait.py
index 3f64ca1..ff48620 100644
--- a/Lib/test/test_concurrent_futures/test_wait.py
+++ b/Lib/test/test_concurrent_futures/test_wait.py
@@ -112,24 +112,25 @@ class WaitTests:
future2]), finished)
self.assertEqual(set(), pending)
- @support.requires_resource('walltime')
def test_timeout(self):
- future1 = self.executor.submit(mul, 6, 7)
- future2 = self.executor.submit(time.sleep, 6)
+ short_timeout = 0.050
+ long_timeout = short_timeout * 10
+
+ future = self.executor.submit(time.sleep, long_timeout)
finished, pending = futures.wait(
[CANCELLED_AND_NOTIFIED_FUTURE,
EXCEPTION_FUTURE,
SUCCESSFUL_FUTURE,
- future1, future2],
- timeout=5,
+ future],
+ timeout=short_timeout,
return_when=futures.ALL_COMPLETED)
self.assertEqual(set([CANCELLED_AND_NOTIFIED_FUTURE,
EXCEPTION_FUTURE,
- SUCCESSFUL_FUTURE,
- future1]), finished)
- self.assertEqual(set([future2]), pending)
+ SUCCESSFUL_FUTURE]),
+ finished)
+ self.assertEqual(set([future]), pending)
class ThreadPoolWaitTests(ThreadPoolMixin, WaitTests, BaseTestCase):
diff --git a/Misc/NEWS.d/next/Tests/2023-09-28-14-47-14.gh-issue-109594.DB5KPP.rst b/Misc/NEWS.d/next/Tests/2023-09-28-14-47-14.gh-issue-109594.DB5KPP.rst
new file mode 100644
index 0000000..5a4ae2b
--- /dev/null
+++ b/Misc/NEWS.d/next/Tests/2023-09-28-14-47-14.gh-issue-109594.DB5KPP.rst
@@ -0,0 +1,4 @@
+Fix test_timeout() of test_concurrent_futures.test_wait. Remove the future
+which may or may not complete depending if it takes longer than the timeout
+ot not. Keep the second future which does not complete before wait()
+timeout. Patch by Victor Stinner.