[issue14308] '_DummyThread' object has no attribute '_Thread__block'
Charles-François Natali
report at bugs.python.org
Thu Apr 19 23:11:13 CEST 2012
Charles-François Natali <neologix at free.fr> added the comment:
> Here is a complete patch + tests for 2.7.
I like the test.
However there's something I find strange with the patch:
"""
diff --git a/Lib/threading.py b/Lib/threading.py
--- a/Lib/threading.py
+++ b/Lib/threading.py
@@ -887,7 +887,7 @@ def _after_fork():
ident = _get_ident()
thread._Thread__ident = ident
new_active[ident] = thread
- else:
+ elif not isinstance(thread, _DummyThread):
# All the others are already stopped.
thread._Thread__stop()
"""
Is it really the caller's job to check that the thread is not a dummy thread?
IMO it should be _DummyThread's stop() method that does the right thing, either by overriding Thread's stop() method in _DummyThread or by puting the check inside Thread.stop(), like what's done inside thread._reset_internal_locks():
"""
if hasattr(self, '_Thread__block'): # DummyThread deletes self.__block
self.__block.__init__()
self.__started._reset_internal_locks()
"""
----------
nosy: +neologix
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14308>
_______________________________________
More information about the Python-bugs-list
mailing list