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

2011-01-12 Thread Jason Rennie
Great explanation. Thanks! Jason On Wed, Jan 12, 2011 at 4:40 PM, wrote: > Some reactors have a different implementation of wakeUp than the above, > but they all have the same goal. > > The reactor thread may be doing something which is going to block > indefinitely (WaitForMultipleObjects, se

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

2011-01-12 Thread exarkun
On 06:45 pm, jren...@gmail.com wrote: >On Wed, Jan 12, 2011 at 11:32 AM, Glyph Lefkowitz >wrote: >>The reactor doesn't have a queue of tasks to be completed. It has >>sets of >>various event sources, which it executes in no particular order. > >"queue of tasks" was a guess on my part, but I looke

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

2011-01-12 Thread Jason Rennie
On Wed, Jan 12, 2011 at 11:32 AM, Glyph Lefkowitz wrote: > The reactor doesn't have a queue of tasks to be completed. It has sets of > various event sources, which it executes in no particular order. > "queue of tasks" was a guess on my part, but I looked through the BaseReactor code and found s

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

2011-01-12 Thread Glyph Lefkowitz
On Wed, Jan 12, 2011 at 10:52 AM, Jason Rennie wrote: > Benjamin, sorry for providing you with an incorrect explanation. > Jean-Paul, thank you for correcting my broken understanding of > callWhenRunning. > > Is there a call which puts a function into the reactor's queue of tasks to > be complet

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

2011-01-12 Thread Jason Rennie
Benjamin, sorry for providing you with an incorrect explanation. Jean-Paul, thank you for correcting my broken understanding of callWhenRunning. Is there a call which puts a function into the reactor's queue of tasks to be completed? Thanks, Jason On Wed, Jan 12, 2011 at 10:26 AM, wrote: > A

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

2011-01-12 Thread exarkun
On 03:15 pm, jren...@gmail.com wrote: >Habit, mostly. I think it's a good habit, though. The reason is that >I >wanted to make sure the __init__ code completed before the connectTCP >was >called. In this case, it doesn't matter, but if I had a number of >things I >wanted to do in __init__, it

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

2011-01-12 Thread Jason Rennie
Habit, mostly. I think it's a good habit, though. The reason is that I wanted to make sure the __init__ code completed before the connectTCP was called. In this case, it doesn't matter, but if I had a number of things I wanted to do in __init__, it might matter. Consider: class MyClientProtoco

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

2011-01-12 Thread benjamin.bertrand
One small question about the following code: Why did you use reactor.callWhenRunning in the __init__ method? Why not calling directly reactor.connectTCP? Cheers, Benjamin Från: twisted-python-boun...@twistedmatrix.com [mailto:twisted-python-boun...@twistedmatrix.com] För Jason Rennie Skickat: d

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

2011-01-12 Thread benjamin.bertrand
Nice, this looks much cleaner. I thought about the connection "lost" case. It's quite similar to "fail" (but client should always try to reconnect to host1 in that case). So easy to implement. Thanks a lot! Benjamin Från: twisted-python-boun...@twistedmatrix.com [mailto:twisted-python-boun...@