Re: [Twisted-Python] Deferred instance has no attribute '__getitem__' ??????

2010-07-15 Thread Glyph Lefkowitz
On Jul 15, 2010, at 4:32 PM, Ken MacDonald wrote: > @defer.inlineCallbacks > def round_val(id, value, rule): > """ > Return first element of round_value_and_percent > """ > defer.returnValue(round_value_and_percent(id, value, 0, rule)[0]) > When I do: > re

Re: [Twisted-Python] Twisted HTTP client supporting failover for multiple A records?

2010-07-15 Thread David Bolen
Luke Marsden writes: > We're actually using it to provide redundancy in this instance. In our > application any request for any site can be made to any (live) server, > so having dead servers in the pool of A records doesn't matter so long > as real web browsers failover to some other A record wi

Re: [Twisted-Python] Deferred instance has no attribute '__getitem__' ??????

2010-07-15 Thread Allen Short
> @defer.inlineCallbacks > def round_val(id, value, rule): > """ > Return first element of round_value_and_percent > """ > defer.returnValue(round_value_and_percent(id, value, 0, rule)[0]) > When I do: > result = yield round_val(1, 2, 3) > > I get this: Defe

[Twisted-Python] Deferred instance has no attribute '__getitem__' ??????

2010-07-15 Thread Ken MacDonald
I have a function and two convenience functions, like this: @defer.inlineCallbacks def round_value_and_percent(id, value, percent): daily = 1. params = dict(nutidin=id, valuein=value, dvin=daily) query = "ROUND_NUT_DV" q_result = yield named

Re: [Twisted-Python] What is the minimum effort solution to make inetd-managed twisted-based application?

2010-07-15 Thread exarkun
On 14 Jul, 04:00 pm, twisted-...@udmvt.ru wrote: >On Wed, Jul 14, 2010 at 02:31:46AM -, exar...@twistedmatrix.com >wrote: >>I'll answer whatever questions I can. :) > >Oh, I have some questions... >I asked some questions in the form of suggestions, well, don't take >them seriously, >I only as

Re: [Twisted-Python] Twisted HTTP client supporting failover for multiple A records?

2010-07-15 Thread exarkun
On 01:54 pm, luke-li...@hybrid-logic.co.uk wrote: >On Thu, 2010-07-15 at 14:28 +0100, Reza Lotun wrote: >> > I suspect you can do this without subclassing... pass in IP address, >>and >> > just make sure you pass correct Host header. I forget the exact API >> > though. > >[snip] >But a separate cl

Re: [Twisted-Python] Twisted HTTP client supporting failover for multiple A records?

2010-07-15 Thread Luke Marsden
On Thu, 2010-07-15 at 14:28 +0100, Reza Lotun wrote: > > I suspect you can do this without subclassing... pass in IP address, and > > just make sure you pass correct Host header. I forget the exact API > > though. This makes sense. Conceptually I had considered it to be the responsibility of the w

Re: [Twisted-Python] Twisted HTTP client supporting failover for multiple A records?

2010-07-15 Thread Reza Lotun
> I suspect you can do this without subclassing... pass in IP address, and > just make sure you pass correct Host header. I forget the exact API > though. Yeah, I was about to say, why not just call socket.gethostbyname_ex in deferToThread and in the callback do a regular Agent.request? Reza --

Re: [Twisted-Python] Twisted HTTP client supporting failover for multiple A records?

2010-07-15 Thread Itamar Turner-Trauring
On Thu, 2010-07-15 at 13:33 +0100, Luke Marsden wrote: > Thanks Itamar, this is massively useful. I'll try subclassing > twisted.web.client.Agent to do its own DNS lookups with twisted.names so > as to be aware of the full list of A records returned. It would then > attempt all the IP addresses in

Re: [Twisted-Python] Twisted HTTP client supporting failover for multiple A records?

2010-07-15 Thread Luke Marsden
On Thu, 2010-07-15 at 08:06 -0400, Itamar Turner-Trauring wrote: > On Thu, 2010-07-15 at 10:46 +0100, Reza Lotun wrote: > > > As for connecting to hosts that resolve to multiple A records - I > > presume as a means of load balancing via DNS round robin We're actually using it to provide redundanc

Re: [Twisted-Python] Twisted HTTP client supporting failover for multiple A records?

2010-07-15 Thread Itamar Turner-Trauring
On Thu, 2010-07-15 at 10:46 +0100, Reza Lotun wrote: > As for connecting to hosts that resolve to multiple A records - I > presume as a means of load balancing via DNS round robin - I'm not > quite sure this is natively supported in Twisted. I believe since all > TCP connections are mediated via c

Re: [Twisted-Python] Twisted HTTP client supporting failover for multiple A records?

2010-07-15 Thread Itamar Turner-Trauring
On Thu, 2010-07-15 at 10:46 +0100, Reza Lotun wrote: > I believe since all > TCP connections are mediated via connectTCP hostnames are ultimately > resolved via socket.gethostbyname. Twisted uses a thread pool to do DNS lookups by default, so this shouldn't block anything. _

Re: [Twisted-Python] Twisted HTTP client supporting failover for multiple A records?

2010-07-15 Thread Reza Lotun
Hi Luke, > Is there any existing support for any Twisted HTTP client to simulate > the behaviour of all modern browsers in that -- if an address returns > multiple A records -- and if one IP fails (connection refused, etc) then > the client attempts a number of the other IPs before giving up? As

[Twisted-Python] Twisted HTTP client supporting failover for multiple A records?

2010-07-15 Thread Luke Marsden
Hi all, Is there any existing support for any Twisted HTTP client to simulate the behaviour of all modern browsers in that -- if an address returns multiple A records -- and if one IP fails (connection refused, etc) then the client attempts a number of the other IPs before giving up? If not, wher