How to use the cloudpickle.CloudPickler.save 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
#print 'saving...', len(self.traceStack), obj, type(obj)

        if id(obj) in self.memo: #deal with this better!!!
            CloudPickler.save(self,obj)
            return

        self.lastobj = obj
        #block Numeric and boolean objects
        self.traceStack.append(id(obj))
        startpos = self.file.tell()

        #Do save:
        excp = None
        try:
            CloudPickler.save(self,obj)
        except PicklingError, p:
            excp = p
            if id(obj) not in self.memo:  #forcibly memoize objects for debug printing..
                self.memoize(obj)

        endpos = self.file.tell()
        self.traceStack.pop()

        size = endpos - startpos
        ido = id(obj)
        if excp or size >= self.min_size_to_save:  #save if exception (to print debug) or larger than min_size
            self.objSizes[ido] = size
            if self.traceStack:
                idp = self.traceStack[-1]
                if idp not in self.objChildren:
                    self.objChildren[idp] = []
github idaholab / raven / framework / contrib / cloud / serialization / pickledebug.py View on Github external
def save(self, obj):
        #ignored types:
        t = type(obj)

        #print 'saving...', len(self.traceStack), obj, type(obj)

        if id(obj) in self.memo: #deal with this better!!!
            CloudPickler.save(self,obj)
            return

        self.lastobj = obj
        #block Numeric and boolean objects
        self.traceStack.append(id(obj))
        startpos = self.file.tell()

        #Do save:
        excp = None
        try:
            CloudPickler.save(self,obj)
        except PicklingError, p:
            excp = p
            if id(obj) not in self.memo:  #forcibly memoize objects for debug printing..
                self.memoize(obj)