[Twisted-web] Deferred in proxy.ProxyClient.handleHeader

Ing. Stefan Grosz, BSc stefan at grosz.at
Fri May 28 08:35:15 EDT 2010


i'm currently writing a reverse proxy with twisted and i've a problem with a
function in my handleHeader method.

the code looks simplified like this:

class MyProxyClient(proxy.ProxyClient):
def handleHeader(self, key, value):
if key.lower() == 'location':
clientCreator = protocol.ClientCreator(reactor, Redis, db=3)
redis = yield clientCreator.connectTCP("localhost", 6379)
value = yield redis.get('myproxy:hashcode:%s' % value)

as the handleHeader caller doesn't wait for a deferred to finish, the
location header is
added after handleResponseEnd is already called and therefore never makes it
to the client.

is there a way to convert the non-blocking redis call to a blocking redis
i know that there's a blocking client library for redis but i'd rather use
only txredis if possible.


Stefan Grosz <stefan at grosz.at>
Stadtausstellungs-, Gemeindeausstellungs-, Stadtinformations- und
Gemeindeinformationsplanungs GmbH
A-1100 Wien, Buchengasse 42
Mobil: +43 650 2643435
Fax: +43 7243 57435

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-web/attachments/20100528/6afc718f/attachment.htm 

More information about the Twisted-web mailing list