[New-bugs-announce] [issue12227] multiprocessing.Pool initialization seems to call methods it should not (and on badly formed objects)
report at bugs.python.org
Tue May 31 19:30:31 CEST 2011
New submission from Graham Cummins <grahamiancummins at gmail.com>:
When attempting to pass instances of a custom class in the argument list
of a multiprocessing.Pool.map call, I encounter an inexplicable AttributeError. A simplified test script that creates the bug is included. It fails for both Python 2.7.1 and 3.2 on my 4-core 64 bit linux machine.
Briefly, the code creates a subclass of "dict" that checks for a "_ro" attribute before handling a "__setitem__". Empty instances of this class
can be passed to Pool.map fine, but if they have any content, I get
that multiprocessing/queues.py, line 378 ("recv()"), calls my custom __setitem__, which fails, due to a missing _ro attribute.
This is very confusing. For one thing, much of the Traceback seems
missing. recv() is not directly a call to my customized __setitem__,
and I can't thing why it should ever need to invoke such a call
For another, the custom class _does_ set the _ro attribute, on __init__. Testing for this attribute, or calling __setitem__, succeeds in every other context I've tested, so it seems that the instance that is
being used in the multiprocessing context is not the same underlying object that I pass in.
components: Library (Lib)
title: multiprocessing.Pool initialization seems to call methods it should not (and on badly formed objects)
versions: Python 2.7
Added file: http://bugs.python.org/file22211/bug.py
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce