asyncio - run coroutine in the background

Martin A. Brown martin at
Sat Feb 20 12:45:02 EST 2016

Hello there,

I realize that this discussion of supporting asynchronous name 
lookup requests in DNS is merely a detour in this thread on asyncio, 
but I couldn't resist mentioning an existing tool.

>> getaddrinfo is a notorious pain but I think it's just a library 
>> issue; an async version should be possible in principle.  How 
>> does Twisted handle it?  Does it have a version?
>In a (non-Python) program of mine, I got annoyed by synchronous 
>name lookups, so I hacked around it: instead of using the regular 
>library functions, I just do a DNS lookup directly (which can then 
>be event-based - send a UDP packet, get notified when a UDP packet 
>arrives). Downside: Ignores /etc/nsswitch.conf and /etc/hosts, and 
>goes straight to the name server. Upside: Is able to do its own 
>caching, since the DNS library gives me the TTLs, but 
>gethostbyname/getaddrinfo won't.

Another (non-Python) DNS name lookup library that does practically 
the same thing (along with the shortcomingsn you mentioned, Chris: 
no NSS nor /etc/hosts) is the adns library.  Well, it is DNS, after 

And, there are Python bindings.  I have been quite happy using the 
adns tools (and tools built on the Python bindings) for mass lookups 
(millions of DNS names).  It works very nicely.

Just sharing knowledge of an existing tool,


Martin A. Brown

More information about the Python-list mailing list