[Python-checkins] cpython: Issue #14335: multiprocessing's custom Pickler subclass now inherits from the
antoine.pitrou
python-checkins at python.org
Sat Mar 17 00:28:43 CET 2012
http://hg.python.org/cpython/rev/b2a8310de718
changeset: 75754:b2a8310de718
parent: 75751:8b2668e60aef
user: Antoine Pitrou <solipsis at pitrou.net>
date: Sat Mar 17 00:23:04 2012 +0100
summary:
Issue #14335: multiprocessing's custom Pickler subclass now inherits from the C-accelerated implementation.
Patch by sbt.
files:
Lib/multiprocessing/forking.py | 18 +++++++++---------
Misc/NEWS | 3 +++
2 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/Lib/multiprocessing/forking.py b/Lib/multiprocessing/forking.py
--- a/Lib/multiprocessing/forking.py
+++ b/Lib/multiprocessing/forking.py
@@ -55,18 +55,18 @@
# Try making some callable types picklable
#
-from pickle import _Pickler as Pickler
+from pickle import Pickler
+from copyreg import dispatch_table
+
class ForkingPickler(Pickler):
- dispatch = Pickler.dispatch.copy()
+ _extra_reducers = {}
+ def __init__(self, *args):
+ Pickler.__init__(self, *args)
+ self.dispatch_table = dispatch_table.copy()
+ self.dispatch_table.update(self._extra_reducers)
@classmethod
def register(cls, type, reduce):
- def dispatcher(self, obj):
- rv = reduce(obj)
- if isinstance(rv, str):
- self.save_global(obj, rv)
- else:
- self.save_reduce(obj=obj, *rv)
- cls.dispatch[type] = dispatcher
+ cls._extra_reducers[type] = reduce
def _reduce_method(m):
if m.__self__ is None:
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -27,6 +27,9 @@
Library
-------
+- Issue #14335: multiprocessing's custom Pickler subclass now inherits from
+ the C-accelerated implementation. Patch by sbt.
+
- Issue #10484: Fix the CGIHTTPServer's PATH_INFO handling problem.
- Issue #11199: Fix the with urllib which hangs on particular ftp urls.
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list