[Twisted-Python] Issue with factories

Itamar Shtull-Trauring twisted at itamarst.org
Tue May 28 12:18:45 EDT 2002


If you do reactor.listenTCP on a factory, startFactory and stopFactory are 
never called. I therefore suggest that we add methods doStart and doStop to 
protocol.Factory, like so, and have them called in listenTCP/UDP/SSL, and 
remove calls to start/stopFactory from app.Appliecation:

class Factory:

    running = 0

    def doStart(self):
         if not self.running:
             self.running = 1
             self.startFactory()

    def doStop(self):
         if self.running:
             self.running = 0
             self.stopFactory()

This ensures the start/stopFactory methods will only be called once, even if 
the factory is added to multiple Ports, and makes sure that they get called 
even if the factory is added to the reactor directly.





More information about the Twisted-Python mailing list