[Twisted-Python] Bring multi service up gradually

Thomas Jacob jacob at internet24.de
Fri Jun 16 10:03:00 EDT 2006


Why not simply start the additional
services from the startFactory-method of your mainservice'
protocol factory?

i,e,:

class MainServiceFac(ServerFactory):
    def startFactory(self):
           <possibly call parent's startFactory>
           reactor.listenTCP(.... subservice 1)
           reactor.listenTCP(.... subservice 2)....
           



On Fri, 2006-06-16 at 10:39 -0300, David Pratt wrote:
> Chaz. wrote:
> > I don't think there is a way to insure you will get the ports you want.
> > Why bother testing if the port is available before hand? In between the
> > port being tested and the application using it someone can sneak in and
> > take it.
> 
> Hi Chaz. Thank you for your reply. The reason for the test is that I 
> don't want the other services to start at all if a connection cannot be 
> found to run the main service. I was thinking of writing a simple tester 
> using socket module to determine which addresses are alive first. When 
> it finds one it stops so in my logic I give this address to my 
> ListenTCP/SSL and attempt to start the main service.
> 
> I don't expect the address list to be large. This way no time is lost 
> with the client running through a long backoff cycle on an address that 
> may not be alive only to have to stop it and try a another until one is 
> possibly found.
> 
> I am not aware of something in twisted that evaluates addresses like 
> this as part of a startup solution. In any case, if I see that an 
> address in the list is available, then I would start my main service 
> using it.  When a connection is made to the main address, then I want to 
> start the remaining services since they are useless without the main 
> service.
> 
> Regards,
> David
> 
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://twistedmatrix.com/pipermail/twisted-python/attachments/20060616/39f0f46a/attachment.pgp 


More information about the Twisted-Python mailing list