Pass Timeout To Socket.getaddrinfo
Let's say I'm writing HTTP requests in Python and my DNS server goes down. If I try: import requests requests.get('https://api.twilio.com', timeout=3) and the DNS server is down,
Solution 1:
There is no way to pass a timeout to the getaddrinfo system call, because it does not accept a timeout argument. You can run the lookup in a thread, and then cancel it if it expires.
On Unix machines, you can modify /etc/resolv.conf
to set a timeout for addrinfo lookups.
Post a Comment for "Pass Timeout To Socket.getaddrinfo"