Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #18165
| From | Robert Kern <robert.kern@gmail.com> |
|---|---|
| Subject | Re: pickling instances of metaclass generated classes |
| Date | 2011-12-29 11:08 +0000 |
| References | <2d221d0f-458e-4821-8786-f064b44b3125@p16g2000yqd.googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.4213.1325156924.27778.python-list@python.org> (permalink) |
On 12/29/11 9:55 AM, lars van gemerden wrote: > Hello, > > Can someone help me with the following: > > I am using metaclasses to make classes and these classes to make > instances. Now I want to use multiprocessing, which needs to pickle > these instances. > > Pickle cannot find the class definitions of the instances. I am trying > to add a line to the __new__ of the metaclass to add the new class > under the right name in the right module/place, so pickle can find > it. > > Is this the right approach? Can anyone explain to me where/how to add > these classes for pickle to find and maybe why? Can you post some code (preferably pared down to a minimal example that fails)? I'm not really clear on what you are doing. I would expect that a class defined by a class statement would usually work fine unless if the metaclass is doing something particularly weird to it. In any case, you can probably just explicitly register a reduction function for each type using copy_reg.pickle(): http://docs.python.org/library/copy_reg -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
pickling instances of metaclass generated classes lars van gemerden <lars@rational-it.com> - 2011-12-29 01:55 -0800
Re: pickling instances of metaclass generated classes Robert Kern <robert.kern@gmail.com> - 2011-12-29 11:08 +0000
Re: pickling instances of metaclass generated classes Ian Kelly <ian.g.kelly@gmail.com> - 2011-12-29 12:55 -0700
Re: pickling instances of metaclass generated classes lars van gemerden <lars@rational-it.com> - 2011-12-30 01:50 -0800
Re: pickling instances of metaclass generated classes Peter Otten <__peter__@web.de> - 2011-12-30 12:41 +0100
Re: pickling instances of metaclass generated classes Peter Otten <__peter__@web.de> - 2012-01-01 13:51 +0100
Re: pickling instances of metaclass generated classes lars van gemerden <lars@rational-it.com> - 2011-12-30 03:16 -0800
Re: pickling instances of metaclass generated classes lars van gemerden <lars@rational-it.com> - 2011-12-30 07:56 -0800
Re: pickling instances of metaclass generated classes lars van gemerden <lars@rational-it.com> - 2011-12-30 08:51 -0800
Re: pickling instances of metaclass generated classes Ian Kelly <ian.g.kelly@gmail.com> - 2011-12-30 10:09 -0700
Re: pickling instances of metaclass generated classes lars van gemerden <lars@rational-it.com> - 2012-01-03 03:43 -0800
csiph-web