Hello everyone,

Disclaimer: I'm not a very good programmer and I'm quite new to Python. I
made a script to run through a batch of expiring domain names that need to
be checked for renewal against other data. I can get the WHOIS data fine,
but I am having trouble on a lot of them with DNS queries. I am just trying
to get the primary A record, but a lot of the domains do not have any DNS
records on the listed nameservers (most likely due to a lack of existing
hosting). When these domains come up they halt the script for 30 seconds
before throwing a Timeout exception.

Even when working around that, it still adds 30 seconds to each domain with
no DNS entries in the list. With multi-threading it still seemed to halt the
rest of the script from doing anything anytime one of these domains came up
for 30 seconds. My workaround has been to use socket.gethostbyname() instead
which times out much faster and doesn't seem to lock up the rest of the
script when multi-threaded. I will admit I have no idea if I setup the
dnspython snippet correctly when multi-threading, so that could be my own
fault as well.

I don't know if there is something I can do to make dnspython work for what
I need, or if I should even use it considering socket.gethosybyname() works
fine for now. Not even sure if this would count as a bug to be reported...

Below is example code to reproduce, and the output of the exception which
ALWAYS takes 30 seconds:

import dns.resolver

d = dns.resolver.Resolver()
d.Timeout = 2.0
a = ''

try:
    q = d.query('cgroofing.com', 'A')
    for rdata in q:
        a = rdata.address
except:
    a = 'fail'
    raise
print a

Traceback (most recent call last):
  File "F:\Projects\dnsexample.py", line 9, in <module>
    q = d.query('cgroofing.com', 'A')
  File "C:\Python27\lib\site-packages\dns\resolver.py", line 644, in query
    timeout = self._compute_timeout(start)
  File "C:\Python27\lib\site-packages\dns\resolver.py", line 568, in
_compute_timeout
    raise Timeout
Timeout
_______________________________________________
dnspython-users mailing list
[email protected]
http://howl.play-bow.org/mailman/listinfo.cgi/dnspython-users

Reply via email to