[issue46824] use AI_NUMERICHOST | AI_NUMERICSERV to skip getaddrinfo thread in asyncio

Ben Darnell report at bugs.python.org
Fri Mar 18 12:41:52 EDT 2022


Ben Darnell <ben.darnell at gmail.com> added the comment:

To summarize the justification, this patch does two things: it moves an optimization from create_connection to getaddrinfo, which makes it apply to more callers (including Tornado), and it makes the code simpler and less redundant (net reduction of 47 non-test lines in the patch). 

As far as we can tell, the reason it wasn't done this way in the first place is that at the time getaddrinfo held a global lock on some platforms, but this is no longer true. If there's still some locking in or around getaddrinfo on some platforms (or some libc implementations), this patch would be a bad idea. Is there a good way to test for that? I suppose we could set up a deliberately-slow DNS server and try to call getaddrinfo with AI_NUMERICHOST while another thread is blocked talking to that server, but that seems like a lot of test infrastructure to build out.

----------
nosy: +Ben.Darnell

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46824>
_______________________________________


More information about the Python-bugs-list mailing list