Gaierror: get address info error. If the URL is incorrect or the proxy information is not configured correctly, this error will be reported
I wrote a very simple class to send HTTP requests. Sometimes it runs thousands of times without reporting an error. Sometimes it runs dozens of times without reporting the [11004] error at the beginning. Many tutorials have been found on the Internet, such as adding a disconnect mark on the header, or increasing the number of retries
So, it’s good to try again. If you find an error, sleep for two seconds and resend it
class HTTPsClient(object):
def __init__(self, url):
self.url = url
self.session = requests.session()
def send(self, data=None, **kwargs):
flag = False
while not flag:
try:
response = self.session.request(method='POST', url=self.url, data=data,**kwargs)
except:
print u'[%s] HTTP request failed!!! Preparing to resend....' % get_time()
time.sleep(2)
continue
flag = True
self.session.close()
It doesn’t have to be written as always retrying. You can also set the number of times to retrying
Similar Posts:
- [Solved] requests.exceptions.InvalidSchema: No connection adapters were found for
- python requests [Errno 104] Connection reset by peer
- [Solved] Python request Error: requests.exceptions.ReadTimeout: HTTPSConnectionPool (xxxx)
- MonkeyPatchWarning: Monkey-patching ssl after ssl has already been imported may lead to errors
- Python3 Use urlliburlopen error EOF occurred in violation of protocol (_ssl.c:841)
- Python 2.7 and 3.4 requests Error: No module named ‘zlib’
- Using Python HDFS module to operate Hadoop HDFS
- [Solved] Kibana 7.15.x [error][savedobjects-service] [.kibana] Action failed with ‘Request timed out’. Retrying attempt
- WebSocket Error: Unable to unwrap data, invalid status [CLOSED]
- Using fastcgi_ finish_ Request to achieve asynchronous processing and improve the response speed of the page