Amaury Forgeot d'Arc <[email protected]> added the comment:
> Being able to pickle unbound methods is important. In my project I have
> objects that refer to unbound methods. Now these objects are
> unpickleable. I can't save them to disk and I can't use the
> multiprocessing module on them. That's a big problem.
The multiprocessing module *can* pickle bound and unbound methods (see below),
but only with the multiprocessing.Process class. It does not work with
Pool.map(), for example. The reason is that Process uses the special
ForkingPickler that has special code to handle methods. Pool.map could be
fixed IMO.
Is "ForkingPickler" enough for your needs?
==== mod.py ============
class C:
def foo(self):
print("CALLED")
==== main.py ===========
from mod import C
if __name__ == '__main__':
from multiprocessing import Process
p = Process(target=C().foo)
p.start(); p.join()
p = Process(target=C.foo, args=(C(),))
p.start(); p.join()
----------
nosy: +amaury.forgeotdarc
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue9276>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com