How to use the cloudpickle.CloudPickler.dump function in cloudpickle

To help you get started, we’ve selected a few cloudpickle examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github idaholab / raven / framework / contrib / cloud / serialization / pickledebug.py View on Github external
def dump(self, obj):

        try:
            CloudPickler.dump(self,obj)
        except PicklingError, p:
            cloudLog.exception("pickling failed on %s of type %s."
                           % (self.lastobj, type(self.lastobj)))
            strio = StringIO()

            xmlf = xmlhandlers.XmlWriter(strio,header=False)
            xmlmid = xmlhandlers.XmlStackWriter(xmlf)
            #xmlmid = xmlf

            self.aborting = True
            try: #intentionally crash at partial xml
                self.dump_obj(xmlmid, obj, self.print_top_level, None, {}, abortObject = self.lastobj)
            except DebugPicklingError, e:
                if e.args[0] != 'fake exit':
                    raise
            except RuntimeError, e: # dump_obj will crash w/ infinite recursion if regular dump did