[issue8289] multiprocessing.Process.__init__ pickles all arguments
Ram Rachum
report at bugs.python.org
Fri Apr 2 17:06:49 CEST 2010
New submission from Ram Rachum <cool-rr at cool-rr.com>:
Currently, when you create a Process, all arguments you pass to its __init__ get pickled. I understood this is done because arguments to __init__ almost always become attributes to the Process. Like this:
def MyProcess(multiprocessing.Process):
def __init__(self, whatever):
self.whatever = whatever
Of course, attributes must be pickled so they can be accessed from the separate process (on Windows). And indeed in most cases all arguments to __init__ become attributes, so this makes sense.
But, in some cases you pass in arguments to __init__ that do not become attributes. In my case, __init__ takes an object, and takes some attributes of this object as attributes to itself. The object is unpicklable, but the attributes are. So I had to make some ugly workaround to make the program run.
So I think it would be better if Process would be smart enough to pickle only the arguments that get set as attributes.
----------
components: Library (Lib)
messages: 102172
nosy: cool-RR
severity: normal
status: open
title: multiprocessing.Process.__init__ pickles all arguments
type: feature request
versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue8289>
_______________________________________
More information about the Python-bugs-list
mailing list