This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: test_threading.test_waitfor() timeout (1 hour) on x86 Gentoo 3.x buildbot
Type: Stage:
Components: Library (Lib) Versions: Python 3.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: neologix, python-dev, r.david.murray, vstinner
Priority: normal Keywords: buildbot, patch

Created on 2011-05-17 15:22 by vstinner, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
wait_for_race.diff neologix, 2011-05-17 17:31 review
Messages (5)
msg136164 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2011-05-17 15:22
Builder x86 Gentoo 3.x Build #130:

http://www.python.org/dev/buildbot/all/builders/x86%20Gentoo%203.x/builds/130/steps/test/logs/stdio

[263/354] test_threading
Timeout (1:00:00)!
Thread 0x48f0bb70:
  File "/var/lib/buildslave/3.x.murray-gentoo/build/Lib/threading.py", line 237 in wait
  File "/var/lib/buildslave/3.x.murray-gentoo/build/Lib/threading.py", line 278 in wait_for
  File "/var/lib/buildslave/3.x.murray-gentoo/build/Lib/test/lock_tests.py", line 472 in f
  File "/var/lib/buildslave/3.x.murray-gentoo/build/Lib/test/lock_tests.py", line 37 in task

Thread 0x401aa010:
  File "/var/lib/buildslave/3.x.murray-gentoo/build/Lib/test/lock_tests.py", line 16 in _wait
  File "/var/lib/buildslave/3.x.murray-gentoo/build/Lib/test/lock_tests.py", line 51 in wait_for_finished
  File "/var/lib/buildslave/3.x.murray-gentoo/build/Lib/test/lock_tests.py", line 482 in test_waitfor
  File "/var/lib/buildslave/3.x.murray-gentoo/build/Lib/unittest/case.py", line 407 in _executeTestPart
  File "/var/lib/buildslave/3.x.murray-gentoo/build/Lib/unittest/case.py", line 462 in run
  File "/var/lib/buildslave/3.x.murray-gentoo/build/Lib/unittest/case.py", line 514 in __call__
  File "/var/lib/buildslave/3.x.murray-gentoo/build/Lib/unittest/suite.py", line 105 in run
  File "/var/lib/buildslave/3.x.murray-gentoo/build/Lib/unittest/suite.py", line 67 in __call__
  File "/var/lib/buildslave/3.x.murray-gentoo/build/Lib/unittest/suite.py", line 105 in run
  File "/var/lib/buildslave/3.x.murray-gentoo/build/Lib/unittest/suite.py", line 67 in __call__
  File "/var/lib/buildslave/3.x.murray-gentoo/build/Lib/test/support.py", line 1096 in run
  File "/var/lib/buildslave/3.x.murray-gentoo/build/Lib/test/support.py", line 1184 in _run_suite
  File "/var/lib/buildslave/3.x.murray-gentoo/build/Lib/test/support.py", line 1210 in run_unittest
  File "/var/lib/buildslave/3.x.murray-gentoo/build/Lib/test/test_threading.py", line 743 in test_main
  File "./Lib/test/regrtest.py", line 1044 in runtest_inner
  File "./Lib/test/regrtest.py", line 838 in runtest
  File "./Lib/test/regrtest.py", line 662 in main
  File "./Lib/test/regrtest.py", line 1622 in <module>
msg136165 - (view) Author: Charles-François Natali (neologix) * (Python committer) Date: 2011-05-17 15:37
The sleep is too short:

       def f():
           with cond:
               result = cond.wait_for(lambda : state==4)


      for i in range(5):
          time.sleep(0.01)
          with cond:
          state += 1
          cond.notify()


If state is incremented to 5 before the thread waits on the condition, it's going to wait forever (it can be reproduced easily by removing the sleep).
We could either increase the sleep, or change the predicate to state==5.
msg136171 - (view) Author: Charles-François Natali (neologix) * (Python committer) Date: 2011-05-17 17:31
Here's a one-liner patch using the later approach  (that way we're
sure the test won't hang).
msg136187 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2011-05-17 22:20
New changeset a6b4a00fb1c7 by Victor Stinner in branch '3.2':
Issue #12096: Fix a race condition in test_threading.test_waitfor(). Patch
http://hg.python.org/cpython/rev/a6b4a00fb1c7

New changeset c52807b17e03 by Victor Stinner in branch 'default':
(Merge 3.2) Issue #12096: Fix a race condition in
http://hg.python.org/cpython/rev/c52807b17e03
msg136189 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2011-05-17 22:22
Oh, it is a real bug in the test. Bug fixed by your patch. Thanks, I commited your patch.

I don't wait for the buildbot because it's a sporadic (and rare) failure.
History
Date User Action Args
2022-04-11 14:57:17adminsetgithub: 56305
2011-05-17 22:22:18vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg136189
2011-05-17 22:20:48python-devsetnosy: + python-dev
messages: + msg136187
2011-05-17 17:31:37neologixsetfiles: + wait_for_race.diff
keywords: + patch
messages: + msg136171
2011-05-17 15:51:36r.david.murraysetkeywords: + buildbot
nosy: + r.david.murray
2011-05-17 15:37:00neologixsetnosy: + neologix
messages: + msg136165
2011-05-17 15:22:54vstinnercreate