[Twisted-Python] Bring multi service up gradually

David Pratt fairwinds at eastlink.ca
Fri Jun 16 07:39:56 MDT 2006


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




More information about the Twisted-Python mailing list