Re: [Twisted-Python] client connecting to 2 servers (non simultaneously)

2011-01-11 Thread Jason Rennie
I agree that rotate(-1) is more intuitive. I barely gave it any thought---almost forgot to include an argument for rotate as I initially incorrectly assumed no argument would do something like rotate(-1) :-) Jason On Tue, Jan 11, 2011 at 1:36 PM, Kevin Horn wrote: > Using a deque for this is a

Re: [Twisted-Python] client connecting to 2 servers (non simultaneously)

2011-01-11 Thread Kevin Horn
Using a deque for this is a fantastic idea, though I would have used rotate(-1), as your example looks like it rotate's "backwards" to me. Matter of taste I suppose. It doesn't make much actual difference. Kevin Horn On Tue, Jan 11, 2011 at 7:11 AM, Jason Rennie wrote: > You could probably ge

Re: [Twisted-Python] client connecting to 2 servers (non simultaneously)

2011-01-11 Thread Itamar Turner-Trauring
On Tue, 2011-01-11 at 11:17 +0100, benjamin.bertr...@lfv.se wrote: > Any comments is welcome. It's probably better to use one factory per client connection - easier to distinguish between connections. Not strictly necessary, though. ___ Twisted-Python

Re: [Twisted-Python] client connecting to 2 servers (non simultaneously)

2011-01-11 Thread Jason Rennie
You could probably generalize and simplify by using a collections.deque of hosts/ports and using the rotate() method before each reactor.connectTCP. Also, no need for multiple reactor imports---one at the top of the code is fine. Note that if the connection is "lost" in a non-clean fashion, you m

[Twisted-Python] client connecting to 2 servers (non simultaneously)

2011-01-11 Thread benjamin.bertrand
Hi, I'm new to twisted and I have started to write a new protocol with a TCP client and server. In my protocol, a client should be able to connect to 2 servers (master/slave node - only the master accepts connection). The client should try to connect to server1. If it fails, try to connect to serv