classification
Title: multiprocessing documentation is outdated regarding method picklability
Type: behavior Stage: resolved
Components: Documentation Versions: Python 3.6, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Jelle Zijlstra, berker.peksag, davin, docs@python, memeplex, python-dev
Priority: normal Keywords: patch

Created on 2016-06-04 19:42 by memeplex, last changed 2016-06-12 09:20 by berker.peksag. This issue is now closed.

Files
File name Uploaded Description Edit
issue27221.patch Jelle Zijlstra, 2016-06-05 18:38 right patch review
issue27221-cr.patch Jelle Zijlstra, 2016-06-11 23:03 revised patch review
mm.py berker.peksag, 2016-06-12 08:49
Messages (6)
msg267303 - (view) Author: Memeplex (memeplex) Date: 2016-06-04 19:42
The module documentation recommends...

More picklability

Ensure that all arguments to Process.__init__() are picklable. This means, in particular, that bound or unbound methods cannot be used directly as the target (unless you use the fork start method) — just define a function and use that instead.

...but methods (bound and unbound) are now pickleable (given their self.object is picklable).
msg267452 - (view) Author: Jelle Zijlstra (Jelle Zijlstra) * (Python triager) Date: 2016-06-05 18:34
Patch attached. I also checked that this case is tested, and it looks like the Bunch object in Lib/test/_test_multiprocessing.py uses a method as its target.
msg268294 - (view) Author: Jelle Zijlstra (Jelle Zijlstra) * (Python triager) Date: 2016-06-11 23:03
Thanks for the Rietveld comments. I have attached a new patch.
msg268348 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2016-06-12 08:49
Actually, we can remove the versionchanged directive. The attached script works fine with the spawn start method in Python 3.4.

I will commit the following version:

    Ensure that all arguments to :meth:`Process.__init__` are picklable.
    Also, if you subclass :class:`~multiprocessing.Process` then make sure that
    instances will be picklable when the :meth:`Process.start
    <multiprocessing.Process.start>` method is called.
msg268350 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-06-12 09:19
New changeset 97254031f0b7 by Berker Peksag in branch '3.5':
Issue #27221: Delete an outdated paragraph about pickle support of Process
https://hg.python.org/cpython/rev/97254031f0b7

New changeset 5b9d8b5b1139 by Berker Peksag in branch 'default':
Issue #27221: Merge from 3.5
https://hg.python.org/cpython/rev/5b9d8b5b1139
msg268351 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2016-06-12 09:20
Thanks!
History
Date User Action Args
2016-06-12 09:20:13berker.peksagsetstatus: open -> closed
resolution: fixed
messages: + msg268351

stage: patch review -> resolved
2016-06-12 09:19:30python-devsetnosy: + python-dev
messages: + msg268350
2016-06-12 08:49:05berker.peksagsetfiles: + mm.py

messages: + msg268348
2016-06-11 23:03:06Jelle Zijlstrasetfiles: + issue27221-cr.patch

messages: + msg268294
2016-06-07 15:03:10ned.deilysetnosy: + davin
2016-06-07 07:35:38berker.peksagsetnosy: + berker.peksag
title: [multiprocessing] Doc is outdated regarding method picklability -> multiprocessing documentation is outdated regarding method picklability
versions: + Python 3.6
type: behavior
stage: patch review
2016-06-05 18:38:40Jelle Zijlstrasetfiles: + issue27221.patch
2016-06-05 18:38:19Jelle Zijlstrasetfiles: - issue27233.patch
2016-06-05 18:34:12Jelle Zijlstrasetfiles: + issue27233.patch

nosy: + Jelle Zijlstra
messages: + msg267452

keywords: + patch
2016-06-04 19:42:42memeplexcreate