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
标题: test_threading hang when running as verbose
类型: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.1, Python 3.2, Python 2.7
process
状态: closed Resolution: out of date
Dependencies: 后续:
分配给: gregory.p.smith 抄送列表: Anthony.Kong, berker.peksag, gpolo, gps, gregory.p.smith, jcea, meador.inge, pitrou, r.david.murray
优先级: normal 关键字: patch

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

文件
文件名 上传时间 Description 编辑
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) 日期: 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) * 日期: 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) 日期: 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) 日期: 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) 日期: 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) 日期: 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) 日期: 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) 日期: 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) 日期: 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) 日期: 2014-02-05 14:52
The threading._VERBOSE attribute was removed in issue 13550 (see also changeset http://hg.python.org/cpython/rev/8ec51b2e57c2).
历史
日期 用户 动作 参数
2022-04-11 14:56:40admin修改github: 48438
2014-02-05 14:52:05berker.peksag修改状态: open -> closed

抄送: + berker.peksag
消息: + msg210321

resolution: out of date
stage: needs patch -> resolved
2014-02-03 19:08:04BreamoreBoy修改抄送: - BreamoreBoy
2012-09-13 21:14:57Anthony.Kong修改抄送: + Anthony.Kong
2012-01-04 04:37:31jcea修改抄送: + jcea
2011-01-04 02:42:54gregory.p.smith修改抄送: gregory.p.smith, pitrou, gps, gpolo, r.david.murray, meador.inge, BreamoreBoy
消息: + msg125286
2011-01-04 02:26:21r.david.murray修改状态: closed -> open

消息: + msg125284
resolution: fixed -> (no value)
抄送: gregory.p.smith, pitrou, gps, gpolo, r.david.murray, meador.inge, BreamoreBoy
2011-01-04 00:15:12gregory.p.smith修改状态: open -> closed
抄送: gregory.p.smith, pitrou, gps, gpolo, r.david.murray, meador.inge, BreamoreBoy
resolution: fixed
2011-01-04 00:12:35gregory.p.smith修改assignee: gregory.p.smith

抄送: + gregory.p.smith
2010-12-17 17:46:08pitrou修改优先级: high -> normal
标题: Lib/threading.py causes infinite recursion when running as verbose -> test_threading hang when running as verbose
抄送: pitrou, gps, gpolo, r.david.murray, meador.inge, BreamoreBoy
消息: + msg124235

stage: patch review -> needs patch
2010-12-17 17:24:29r.david.murray修改抄送: + r.david.murray

消息: + msg124232
versions: - Python 2.6
2010-08-03 13:52:59meador.inge修改抄送: + meador.inge
2010-07-31 11:51:47pitrou修改文件: + verbosethreading.patch

消息: + msg112145
2010-07-31 11:38:20pitrou修改消息: + msg112139
2010-07-31 11:34:35pitrou修改抄送: + pitrou, gps

消息: + msg112136
stage: test needed -> patch review
2010-07-31 11:18:25BreamoreBoy修改抄送: + BreamoreBoy
消息: + msg112131
2010-05-11 20:54:13terry.reedy修改versions: + Python 3.2, - Python 3.0
2009-05-16 01:14:49ajaksu2修改优先级: high
type: behavior
stage: test needed
2008-10-23 20:28:22gpolo创建