Issue 4188: test_threading hang when running as verbose (original) (raw)

Created on 2008-10-23 20:28 by gpolo, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
move_Thread__started.diff gpolo,2008-10-23 20:28 review
verbosethreading.patch pitrou,2010-07-31 11:51 review
Messages (10)
msg75149 - (view) Author: Guilherme Polo (gpolo) * (Python committer) Date: 2008-10-23 20:28
Lib/threading.py gets into infinite recursion while testing (or using) it with verbose set. This didn't happen before because Thread.__started didn't use to be an Event, but now it is. Typical situation: _DummyThread calls _Thread__started.set, which calls __started.__cond.notify_all(), which calls __cond.notify(). If there are no waiters, it calls _Verbose._note, which calls currentThread, but if there is no current thread _DummyThread is called, which calls _Thread__started.set ...
msg112131 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010-07-31 11:18
Could someone with knowledge of threading provide a unit test for this, assuming that you want or need to force threading into infinite recursion. Then we can test a patch that only moves two lines.
msg112136 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-07-31 11:34
The patch looks ok. A more robust solution would be to modify _note() so that it never creates a DummyThread, and instead uses the raw thread id if the current thread doesn't have a corresponding Thread object.
msg112139 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-07-31 11:38
I spoke too fast. With the patch, test_3_join_in_forked_from_thread in test_threading still fails with _VERBOSE manually set to True.
msg112145 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-07-31 11:51
Here is a patch with the alternative approach suggested above. There still is the aforementioned test_threading issue when run standalone.
msg124232 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-12-17 17:24
I can confirm that the patch fixes the recursion problem if threading._VERBOSE is set to true, but the test Antoine mentioned hangs when the test suite is run. _VERBOSE is an internal, undocumented facility, so perhaps the priority on this isn't really "high". On the other hand, Antoine's patch takes things from non-functional to at least partially functional, so perhaps it is worth applying as is, pending someone figuring out where the test hang is coming from. I looked in to this briefly, but I have no clue how to trigger this in a unit test, since it seems to happen when regrtest imports logging which imports threading, and appears to my threading-ignorant eyes to be tied to conditions that only exist at initial module import.
msg124235 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-12-17 17:46
Ok, I committed the patch in r87341 (3.2), r87342 (3.1) and r87343 (2.7).
msg125284 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2011-01-04 02:26
The hanging test still hangs for me with _VERBOSE set to True on py3k trunk.
msg125286 - (view) Author: Gregory P. Smith (gregory.p.smith) * (Python committer) Date: 2011-01-04 02:42
sorry, i saw the patches committed and thought that had fixed it. oops. still more to be done.
msg210321 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2014-02-05 14:52
The threading._VERBOSE attribute was removed in issue 13550 (see also changeset http://hg.python.org/cpython/rev/8ec51b2e57c2).
History
Date User Action Args
2022-04-11 14:56:40 admin set github: 48438
2014-02-05 14:52:05 berker.peksag set status: open -> closednosy: + berker.peksagmessages: + resolution: out of datestage: needs patch -> resolved
2014-02-03 19:08:04 BreamoreBoy set nosy: - BreamoreBoy
2012-09-13 21:14:57 Anthony.Kong set nosy: + Anthony.Kong
2012-01-04 04:37:31 jcea set nosy: + jcea
2011-01-04 02:42:54 gregory.p.smith set nosy:gregory.p.smith, pitrou, gps, gpolo, r.david.murray, meador.inge, BreamoreBoymessages: +
2011-01-04 02:26:21 r.david.murray set status: closed -> openmessages: + resolution: fixed -> (no value)nosy:gregory.p.smith, pitrou, gps, gpolo, r.david.murray, meador.inge, BreamoreBoy
2011-01-04 00:15:12 gregory.p.smith set status: open -> closednosy:gregory.p.smith, pitrou, gps, gpolo, r.david.murray, meador.inge, BreamoreBoyresolution: fixed
2011-01-04 00:12:35 gregory.p.smith set assignee: gregory.p.smithnosy: + gregory.p.smith
2010-12-17 17:46:08 pitrou set priority: high -> normaltitle: Lib/threading.py causes infinite recursion when running as verbose -> test_threading hang when running as verbosenosy:pitrou, gps, gpolo, r.david.murray, meador.inge, BreamoreBoymessages: + stage: patch review -> needs patch
2010-12-17 17:24:29 r.david.murray set nosy: + r.david.murraymessages: + versions: - Python 2.6
2010-08-03 13:52:59 meador.inge set nosy: + meador.inge
2010-07-31 11:51:47 pitrou set files: + verbosethreading.patchmessages: +
2010-07-31 11:38:20 pitrou set messages: +
2010-07-31 11:34:35 pitrou set nosy: + pitrou, gpsmessages: + stage: test needed -> patch review
2010-07-31 11🔞25 BreamoreBoy set nosy: + BreamoreBoymessages: +
2010-05-11 20:54:13 terry.reedy set versions: + Python 3.2, - Python 3.0
2009-05-16 01:14:49 ajaksu2 set priority: hightype: behaviorstage: test needed
2008-10-23 20:28:22 gpolo create