Python Pickling Issue

Brandon Harris brandon.harris at reelfx.com
Thu Nov 3 10:42:08 EDT 2011


I have written a fairly large DAG with python and I've run into an issue 
when attempting to pickle the data to disk.
It will pickle fine the first time, but if I call pickle again, it 
throws this error.

/usr/lib64/python2.6/copy_reg.py in _reduce_ex(self, proto)
      68     else:
      69         if base is self.__class__:
---> 70             raise TypeError, "can't pickle %s objects" % 
base.__name__
      71         state = base(self)
      72     args = (self.__class__, base, state)

TypeError: can't pickle function objects

I'm calling
save_file = open('my_file.rsf', 'w')
cPickle.dump(self, save_file)

I have attempted to pickle the object to a different file after the 
first time, but the error is still thrown.

This wouldn't be very hard to track down if the error gave any 
indication as to where or what this function it can't pickle is, so
if there's any possible way to at least get the name of what's failing 
to be pickled, that would be a win.

Thanks in advance for all replies.

Brandon L. Harris




More information about the Python-list mailing list