diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-03-16 23:23:04 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-03-16 23:23:04 (GMT) |
commit | 846fd302a0155ca6d277cb274ca6c39d08860013 (patch) | |
tree | ba94c7c823a491fc17a0fb0247e73e758592d378 /Lib/multiprocessing | |
parent | d656958915de825f1c1f298fb8183555141e4956 (diff) | |
download | cpython-846fd302a0155ca6d277cb274ca6c39d08860013.zip cpython-846fd302a0155ca6d277cb274ca6c39d08860013.tar.gz cpython-846fd302a0155ca6d277cb274ca6c39d08860013.tar.bz2 |
Issue #14335: multiprocessing's custom Pickler subclass now inherits from the C-accelerated implementation.
Patch by sbt.
Diffstat (limited to 'Lib/multiprocessing')
-rw-r--r-- | Lib/multiprocessing/forking.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/Lib/multiprocessing/forking.py b/Lib/multiprocessing/forking.py index b7de567..020508a 100644 --- a/Lib/multiprocessing/forking.py +++ b/Lib/multiprocessing/forking.py @@ -55,18 +55,18 @@ def assert_spawning(self): # 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: |