[Twisted-Python] How to make a service dependent of another?

Jean-Paul Calderone exarkun at divmod.com
Fri May 15 10:38:01 EDT 2009

On Fri, 15 May 2009 11:11:58 +0300, coder_gus <coder_gus at lavabit.com> wrote:
>I have a pb client and a tcp server. How can I make the server start
>only after/if the client started?

In general, the answer to "how do I do X when Y?" is "Put the code to do X
in the callback that tells you Y has happened."

So, for example, if you're using PBClientFactory.login, you might add a
callback to the Deferred it returns which starts your TCP server.  ie,

    f = PBClientFactory(...)
    d = f.login(...)
    def cbLoggedIn(avatar):
    reactor.connectTCP(..., f)


More information about the Twisted-Python mailing list