homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author amaury.forgeotdarc
Recipients alexandre.vassalotti, amaury.forgeotdarc, belopolsky, cool-RR, daniel.urban, eric.araujo, exarkun, hinsen, lemburg, loewis, obamausa8, pitrou, rhettinger
Date 2011年03月01日.21:29:12
SpamBayes Score 2.0863635e-07
Marked as misclassified No
Message-id <1299014955.28.0.462467189097.issue9276@psf.upfronthosting.co.za>
In-reply-to
Content
> 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()
History
Date User Action Args
2011年03月01日 21:29:15amaury.forgeotdarcsetrecipients: + amaury.forgeotdarc, lemburg, loewis, rhettinger, hinsen, exarkun, belopolsky, pitrou, alexandre.vassalotti, eric.araujo, obamausa8, daniel.urban, cool-RR
2011年03月01日 21:29:15amaury.forgeotdarcsetmessageid: <1299014955.28.0.462467189097.issue9276@psf.upfronthosting.co.za>
2011年03月01日 21:29:12amaury.forgeotdarclinkissue9276 messages
2011年03月01日 21:29:12amaury.forgeotdarccreate

AltStyle によって変換されたページ (->オリジナル) /