[Twisted-Python] Cannot pickle <type 'DB'> objects

glyph at divmod.com glyph at divmod.com
Mon Apr 9 11:53:24 EDT 2007

On 01:34 pm, exarkun at divmod.com wrote:
>On Mon, 09 Apr 2007 15:21:50 +0200, Roland Hedberg 
><roland.hedberg at adm.umu.se> wrote:

>>Is there anyway by which I can tell mktap to "forget" about the
>>sleepycat database or ... ?

>Two possibilities jump out at me:
>  - Don't invoke the initialization code of that package in makeService,
>    wait until the startService method of the service you create is 
>    and invoke it then.  This will prevent the DB from being opened 
>    the application is actually started (ie, when twistd is run).

This has the added advantage of working with the --uid and --gid options 
of twistd as well.  If your objects are created as the service is 
created, they will be created (and the database opened) as root.  You 
almost always want to wait until the service actually starts up, i.e. 
until Twisted has already daemonized, already shed privileges, to 
actually open files and databases.
>  - Don't use mktap, just use twistd

There is also probably no reason to use mktap for a case like this any 
more though, and there are no tests to ensure that pickles remain 
compatible across Twisted or Python versions.  Not only are there no 
automated tests, but as far as I know nobody is still using taps as a 
method persisting configuration any more, so it is unlikely there is any 
mechanism for us to notice if pickle compatibility is broken.

In other words, you're probably better off taking both of JP's 
suggestions rather than just one.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20070409/8042406b/attachment.htm 

More information about the Twisted-Python mailing list