[Twisted-Python] How can I run code when the protocol is done being built?

Jean-Paul Calderone exarkun at divmod.com
Fri Mar 28 11:39:44 EDT 2008

On Fri, 28 Mar 2008 16:33:48 +0100, Gabriel Rossetti <mailing_lists at evotex.ch> wrote:
>I need to use the factory ref in a protocol instance at the begining of the 
>protocol instance's life. Normally I do my initializing code in __init__(), 
>but I can't access self.factory from inside __init__(), since it's only 
>assigned after the protocol has ben built by the factory. A hack is to use 
>reactor.callLater(), but I don't like hacks, and it's messing up my unit 
>tests (using trial), I get REACTOR UNCLEAN errors. Is there a cleaner way to 
>run initialization code, in a protocol, but after it has been built (and 
>factory has been assigned)?

Do the initialization in connectionMade (or makeConnection) instead of in


More information about the Twisted-Python mailing list