On May 8, 5:48 am, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > I'm wondering if anyone can help with a workaround for a problem I > > currently have. I'm trying to set up a prefork tcp server. > > Specifically, I'm setting up a server that forks children and has them > > listen on pipes created with os.pipe(). The parent process for the > > group starts an inet:tcp server on a given port. In the parent, after > > a "socket.accept()", I'm trying to pickle the connection object to > > send over an IPC pipe (as stated previously), but I get the following > > error: > > > File "/usr/lib/python2.4/copy_reg.py", line 76, in _reduce_ex > > raise TypeError("a class that defines __slots__ without " > > TypeError: a class that defines __slots__ without defining > > __getstate__ cannot be pickled > > > Does anyone know of a workaround for this? Maybe my approach to this > > is wrong? Any help would be appreciated. > > The error-message is pretty clear I'd say. You use slots - so you are > responsible yourself for implementing the pickling-protocol using > __getstate__ and __setstate__. Looking at the pickle-docs should give you > an idea. > > But the really easy solution is: do not use slots. They are intended as > memory-consumption optimization technique, *not* as "I want to declare my > attributes explicitly"-mechanism. So - get rid of them and be a happy > pickler. > > Diez
The thing is, I'm not using slots by choice. I'm using the standard lib "socket" class, which apparently uses slots. -- http://mail.python.org/mailman/listinfo/python-list