[PEAK] Pickable Components and Python Remote Objects
Sigve Tjora
public at tjora.no
Tue Sep 20 16:26:50 EDT 2005
Hi again,
Thanks for prompt answer Phillip.
I am sorry for the fairly untested code-example I sent you. It turns out
that it only happens when I run the example after a specific python file
which has been run with the %run magic command of ipython. So it is
probably some not really important corner case between ipython and peak.
For the record, I have attached the minimal procedure to reproduce the
error at the end of this mail. However I do not intend nor need anyone
to fix this, I only add it as a reference if anyone should turn into the
same problem.
Regards Sigve
I am using IPython 0.6.15, Python 2.4.1,
PEAK-0.5a4dev_r2085-py2.4-win32.egg on Windows XP.
Make a file peakpickle.py containing:
from peak.api import *
import pickle
class MyComponent(binding.Component):
pass
Then enter the following commands in the IPython:
IPython 0.6.15 -- An enhanced Interactive Python.
? -> Introduction to IPython's features.
%magic -> Information about IPython's 'magic' % functions.
help -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.
In [1]: %run peakpickle.py
In [2]: class A(binding.Component):pass
...:
In [3]: a = A()
In [4]: pickle.dumps(a)
---------------------------------------------------------------------------
pickle.PicklingError Traceback (most recent
call la
t)
D:\PhD\fpga\pyfuse\<console>
c:\python24\lib\pickle.py in dumps(obj, protocol, bin)
1384 def dumps(obj, protocol=None, bin=None):
1385 file = StringIO()
-> 1386 Pickler(file, protocol, bin).dump(obj)
1387 return file.getvalue()
1388
c:\python24\lib\pickle.py in dump(self, obj)
229 if self.proto >= 2:
230 self.write(PROTO + chr(self.proto))
--> 231 self.save(obj)
232 self.write(STOP)
233
c:\python24\lib\pickle.py in save(self, obj)
336
337 # Save the reduce() output and finally memoize the object
--> 338 self.save_reduce(obj=obj, *rv)
339
340 def persistent_id(self, obj):
c:\python24\lib\pickle.py in save_reduce(self, func, args, state,
listitems, di
titems, obj)
413 else:
414 save(func)
--> 415 save(args)
416 write(REDUCE)
417
c:\python24\lib\pickle.py in save(self, obj)
291 f = self.dispatch.get(t)
292 if f:
--> 293 f(self, obj) # Call unbound method with explicit self
294 return
295
c:\python24\lib\pickle.py in save_tuple(self, obj)
574 write(MARK)
575 for element in obj:
--> 576 save(element)
577
578 if id(obj) in memo:
c:\python24\lib\pickle.py in save(self, obj)
300 issc = 0
301 if issc:
--> 302 self.save_global(obj)
303 return
304
c:\python24\lib\pickle.py in save_global(self, obj, name, pack)
758 klass = getattr(mod, name)
759 except (ImportError, KeyError, AttributeError):
--> 760 raise PicklingError(
761 "Can't pickle %r: it's not found as %s.%s" %
762 (obj, module, name))
PicklingError: Can't pickle <class '__main__.A'>: it's not found as
__main__.A
In [5]:
More information about the PEAK
mailing list