[Twisted-Python] Async reverse DNS lookup?

exarkun at divmod.com exarkun at divmod.com
Mon Sep 27 21:32:17 EDT 2004

On Mon, 27 Sep 2004 18:17:02 -0400 (EDT), Yun Mao <maoy at cis.upenn.edu> wrote:
>Thank you!
> 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
> finish.
> 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?
> Yun

  The reactor has a method, "installResolver", which you can pass an object which impleemnts IResolverSimple.  twisted.names.client.theResolver should be usable in this capacity.  It is little tested, as most people simply accept the default blocking lookup behavior, so there may be problems.  If you run across any, please give a shout :)  I'm more than happy to attempt to fix them.


More information about the Twisted-Python mailing list