[Twisted-Python] How can I run code when the protocol is done being built?
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
On Fri, 28 Mar 2008 16:33:48 +0100, Gabriel Rossetti <mailing_lists@evotex.ch> wrote:
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)?
Do the initialization in connectionMade (or makeConnection) instead of in __init__. Jean-Paul
participants (2)
-
Gabriel Rossetti -
Jean-Paul Calderone