Permanent DNS caching not used by Python socket.getaddrinfo / mercurial

I used to have a very slow DNS lookup on my Ubuntu machine when connecting through a single modem / ISP. I followed the instructions (for example, here ) to use permanent DNS caching, so I do not repeat repeated DNS queries, and everything became much faster. However, I noticed that when pulling / clicking on repositories at the mercury level it was very slow even tolerate very small changes. Looking deeper, I found that _socket.getaddrinfo , that is, DNS _socket.getaddrinfo , was busy all the time. Why all web browsers use the information in /etc/pdnsd.conf to use old dns requests, this is not the case for python sockets. How can I use mercury to use cached queries?

Update

It is also possible that getaddrinfo tries to get both ipv4 and ipv6 addresses and returns a response only after it could not find the ipv6 address. I am not sure how to check this, that is, regardless of whether the delay is related to ipv6, inconsistency, or both.

Update

This may be due to ipv6 requests, as suggested in the answer here , I will need to check as soon as I get a chance.

+4
source share
2 answers

Thanks to this post in the python list, it seems that if you use BIND, then python getaddrinfo uses cached DNS lookups. After installing BIND and starting it, repeated DNS queries are executed instantly.

+1
source

Pythons socket.getaddrinfo () uses the getaddrinfo () OS (over libc). - This has nothing to do with Python. If pdns is already set up to be in the permission chain, then different resolution rates are based on different requests. - Take a closer look at what exact getaddrinfo () requests are fast, slow.

+1
source

Source: https://habr.com/ru/post/1270537/


All Articles