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

Jean-Paul Calderone exarkun at divmod.com
Mon Apr 9 09:34:05 EDT 2007

On Mon, 09 Apr 2007 15:21:50 +0200, Roland Hedberg <roland.hedberg at adm.umu.se> wrote:
>I've written a system that consists of a central module, one or more
>receiver modules and one or more sender modules.
>Different modules might handle different protocols, and this is one of
>the reasons I choose twisted as framework.
>But now I've got a problem I don't know how to solve.
>One of the sender modules is depending on another package and that
>package opens a sleepycat database at initialization.
>Which is not playing nice with mktap. So, now when I use mktap I get an
>exception with the error code shown on the subject line of this mail.
>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 called,
    and invoke it then.  This will prevent the DB from being opened until
    the application is actually started (ie, when twistd is run).

  - Don't use mktap, just use twistd: since Twisted 2.5, these two are
    roughly equivalent:

      mktap foo --bar
      twistd -f foo.tap


      twistd foo --bar

    The most significant difference being that the latter doesn't create a
    tap file initially.


More information about the Twisted-Python mailing list