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.

Title: test_threading hang when running as verbose
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.1, Python 3.2, Python 2.7
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: gregory.p.smith Nosy List: Anthony.Kong, berker.peksag, gpolo, gps, gregory.p.smith, jcea, meador.inge, pitrou, r.david.murray
Priority: normal Keywords: patch

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

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/ 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
Date User Action Args
2022-04-11 14:56:40adminsetgithub: 48438
2014-02-05 14:52:05berker.peksagsetstatus: open -> closed

nosy: + berker.peksag
messages: + msg210321

resolution: out of date
stage: needs patch -> resolved
2014-02-03 19:08:04BreamoreBoysetnosy: - BreamoreBoy
2012-09-13 21:14:57Anthony.Kongsetnosy: + Anthony.Kong
2012-01-04 04:37:31jceasetnosy: + jcea
2011-01-04 02:42:54gregory.p.smithsetnosy: gregory.p.smith, pitrou, gps, gpolo, r.david.murray, meador.inge, BreamoreBoy
messages: + msg125286
2011-01-04 02:26:21r.david.murraysetstatus: closed -> open

messages: + msg125284
resolution: fixed -> (no value)
nosy: gregory.p.smith, pitrou, gps, gpolo, r.david.murray, meador.inge, BreamoreBoy
2011-01-04 00:15:12gregory.p.smithsetstatus: open -> closed
nosy: gregory.p.smith, pitrou, gps, gpolo, r.david.murray, meador.inge, BreamoreBoy
resolution: fixed
2011-01-04 00:12:35gregory.p.smithsetassignee: gregory.p.smith

nosy: + gregory.p.smith
2010-12-17 17:46:08pitrousetpriority: high -> normal
title: Lib/ causes infinite recursion when running as verbose -> test_threading hang when running as verbose
nosy: pitrou, gps, gpolo, r.david.murray, meador.inge, BreamoreBoy
messages: + msg124235

stage: patch review -> needs patch
2010-12-17 17:24:29r.david.murraysetnosy: + r.david.murray

messages: + msg124232
versions: - Python 2.6
2010-08-03 13:52:59meador.ingesetnosy: + meador.inge
2010-07-31 11:51:47pitrousetfiles: + verbosethreading.patch

messages: + msg112145
2010-07-31 11:38:20pitrousetmessages: + msg112139
2010-07-31 11:34:35pitrousetnosy: + pitrou, gps

messages: + msg112136
stage: test needed -> patch review
2010-07-31 11:18:25BreamoreBoysetnosy: + BreamoreBoy
messages: + msg112131
2010-05-11 20:54:13terry.reedysetversions: + Python 3.2, - Python 3.0
2009-05-16 01:14:49ajaksu2setpriority: high
type: behavior
stage: test needed
2008-10-23 20:28:22gpolocreate