New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
multiprocessing.dummy craches when self._parent._children does not exist #59086
Comments
multiprocessing.dummy crashes when attempting to create a ThreadPool from a Thread. The following code will crush on 2.7.3: import multiprocessing.dummy
import threading
class Worker(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
def run(self):
poll = multiprocessing.dummy.Pool(5)
print str(poll)
w = Worker()
w.start() will crush with the following traceback: poll = multiprocessing.dummy.Pool(5)
File "C:\Python27\lib\multiprocessing\dummy\__init__.py", line 150, in Pool
return ThreadPool(processes, initializer, initargs)
File "C:\Python27\lib\multiprocessing\pool.py", line 685, in __init__
Pool.__init__(self, processes, initializer, initargs)
File "C:\Python27\lib\multiprocessing\pool.py", line 136, in __init__
self._repopulate_pool()
File "C:\Python27\lib\multiprocessing\pool.py", line 199, in _repopulate_pool
w.start()
File "C:\Python27\lib\multiprocessing\dummy\__init__.py", line 73, in start
self._parent._children[self] = None
AttributeError: 'Worker' object has no attribute '_children' If you have access to the thread itself, you can set the _children attribute youself (w._children = weakref.WeakKeyDictionary()), but it is not possible with threads different from threading.thread (Such as PyQt4's QThread thread, which is essential for GUI programming). The fix that I found is to edit the Python27\Lib\multiprocessing\dummy\init.py file. The crashing code is line number 73. if hasattr(self._parent, '_children'):
self._parent._children[self] = None That way the code is fixed. |
New changeset 1f5d2642929a by Richard Oudkerk in branch '2.7': New changeset 0528ec18e230 by Richard Oudkerk in branch '3.2': |
3.3 commit is http://hg.python.org/cpython/rev/9373ca8c6c55 |
I'll, remember that in future;-) Closing. |
Is this a duplicate for http://bugs.python.org/issue10015 |
Since this is already fixed and closed, the question is more relevant to bpo-10015 and whether it should be closed. The answer seems to be yes. |
By the way, thanks for noticing, so it *can* be closed. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: