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

Gabriel Rossetti mailing_lists at evotex.ch
Fri Mar 28 11:33:48 EDT 2008


Hello,

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)?

Thanks,
Gabriel




More information about the Twisted-Python mailing list