diff --git a/IPython/parallel/client/view.py b/IPython/parallel/client/view.py index d7a5ded..bbd474a 100644 --- a/IPython/parallel/client/view.py +++ b/IPython/parallel/client/view.py @@ -519,6 +519,12 @@ class DirectView(View): pickleutil.use_dill() return self.apply(pickleutil.use_dill) + def use_cloudpickle(self): + """Expand serialization support with cloudpickle. + """ + pickleutil.use_cloudpickle() + return self.apply(pickleutil.use_cloudpickle) + @sync_results @save_ids diff --git a/IPython/utils/pickleutil.py b/IPython/utils/pickleutil.py index d3fed87..01988fe 100644 --- a/IPython/utils/pickleutil.py +++ b/IPython/utils/pickleutil.py @@ -68,6 +68,26 @@ def use_dill(): # disable special function handling, let dill take care of it can_map.pop(FunctionType, None) +def use_cloudpickle(): + """use cloudpickle to expand serialization support + + adds support for object methods and closures to serialization. + """ + from cloud.serialization import cloudpickle + + global pickle + pickle = cloudpickle + + try: + from IPython.kernel.zmq import serialize + except ImportError: + pass + else: + serialize.pickle = cloudpickle + + # disable special function handling, let cloudpickle take care of it + can_map.pop(FunctionType, None) + #------------------------------------------------------------------------------- # Classes