[Python-checkins] bpo-32692: Fix test_threading.test_set_and_clear() (GH-8331)

Miss Islington (bot) webhook-mailer at python.org
Thu Jul 19 05:27:51 EDT 2018


https://github.com/python/cpython/commit/339e0c1296c61c9dbc1f8f880c5c668bf4007e5e
commit: 339e0c1296c61c9dbc1f8f880c5c668bf4007e5e
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2018-07-19T02:27:42-07:00
summary:

bpo-32692: Fix test_threading.test_set_and_clear() (GH-8331)


Increase the timeout: give timeout x 4 instead of timeout x 2 to
threads to wait until the Event is set, but reduce the sleep from 500
ms to 250 ms. So the test should be more reliable and faster!
(cherry picked from commit 81950495ba2c36056e0ce48fd37d514816c26747)

Co-authored-by: Victor Stinner <vstinner at redhat.com>

files:
M Lib/test/lock_tests.py

diff --git a/Lib/test/lock_tests.py b/Lib/test/lock_tests.py
index 5b1f033c6f80..65fa4d87d4ce 100644
--- a/Lib/test/lock_tests.py
+++ b/Lib/test/lock_tests.py
@@ -405,12 +405,13 @@ def test_set_and_clear(self):
         # cleared before the waiting thread is woken up.
         evt = self.eventtype()
         results = []
+        timeout = 0.250
         N = 5
         def f():
-            results.append(evt.wait(1))
+            results.append(evt.wait(timeout * 4))
         b = Bunch(f, N)
         b.wait_for_started()
-        time.sleep(0.5)
+        time.sleep(timeout)
         evt.set()
         evt.clear()
         b.wait_for_finished()



More information about the Python-checkins mailing list