[Twisted-Python] Async reverse DNS lookup?
maoy at cis.upenn.edu
Mon Sep 27 18:17:02 EDT 2004
Continuing on the topic of DNS lookup, does the default setting call
socket.gethostbyname() when each time I do connectTCP()? I also noticed
that my program is not responsive when DNS operation took a long time to
I took a short look into the code: the base.py says that if self.resovler
is None then it will call _internalResolve(), which calls gethostbyname().
If I am right, how to set the default resolver?
On Mon, 27 Sep 2004 exarkun at divmod.com wrote:
> On Mon, 27 Sep 2004 15:57:33 -0400 (EDT), Yun Mao <maoy at cis.upenn.edu> wrote:
> >I'm currently using socket.gethostbyaddr(ip), and sometimes it will block
> > my program for quite a while. What's the correct way to do this in
> > twisted? Do I have to create a thread for that? Thanks!
> > Yun
> from twisted.names import client
> from twisted.python import util, log
> from twisted.internet import reactor
> addr = '220.127.116.11'
> ptr = '.'.join(addr.split('.')[::-1]) + '.in-addr.arpa'
> ).addCallback(lambda (ans, auth, add): util.println(ans.payload.name)
> ).addBoth(lambda r: reactor.stop()
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
More information about the Twisted-Python