asyncio - run coroutine in the background

Chris Angelico rosuav at
Sat Feb 20 04:02:18 EST 2016

On Sat, Feb 20, 2016 at 7:59 PM, Marko Rauhamaa <marko at> wrote:
> Chris Angelico <rosuav at>:
>> 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.
> Ditto in a Python program of mine, although I don't bother with caching:
> the DNS server is perfectly capable of caching the entries for me.

If you know you have a local DNS server, sure. Mine is written for a
generic situation where that can't be depended on, so it caches
itself. But it's no big deal.


More information about the Python-list mailing list