[Twisted-web] web2: reverse dns lookup in twisted reactor thread

glyph at divmod.com glyph at divmod.com
Tue Jul 11 16:14:58 CDT 2006


On Wed, 12 Jul 2006 01:11:16 +0530, Div Shekhar <div.shekhar at gmail.com> wrote:

>I'm planning to solve this by commenting out line 490 in
>twisted/web2/channel/http.py:
>
>        host.host = _cachedGetHostByAddr(host.host)
>
>I'd recommend that this lookup be moved to wsgi thread and/or be
>turned off by default. Just wanted to check - am I missing something?

Wow, thanks for bringing that to my attention.  There's a lot wrong with that function.

 - There's no docstring explaining why the cache is necessary, e.g. why your local caching nameserver isn't good enough.

 - It sets the "host" attribute on the transport, which is not documented by ITransport.

 - As you've noticed, it uses gethostbyaddr rather than the reactor's resolver.  If it really needs to use a hostname, and not a numeric address, it's going to need to return a Deferred.

 - "ISSLTransport(x, None) is not None" seems to have evolved into an idiom, but I'm pretty sure that this is just a reflection of the bad, old interfaces system.  Anybody else know if there's a reason for this rather than a providedBy check?

I'll wait a bit for someone who knows about why it is the way it is before making tickets though.



More information about the Twisted-web mailing list