我有一个循环遍历表行的命令行Python脚本,使用python-requests库对每行的API发出PUT请求。语法如下:
updateResponse = requests.put(updateRowUrl, data=json.dumps(payload), headers=headers)
这个过程适用于我,但是我有一个用户在进程成功调用几次后收到以下错误:
File "C:\Python27\lib\site-packages\requests\api.py", line 105, in put
return request('put', url, data=data, **kwargs)
File "C:\Python27\lib\site-packages\requests\api.py", line 49, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Python27\lib\site-packages\requests\sessions.py", line 457, in reques
t
resp = self.send(prep, **send_kwargs)
File "C:\Python27\lib\site-packages\requests\sessions.py", line 569, in send
r = adapter.send(request, **kwargs)
File "C:\Python27\lib\site-packages\requests\adapters.py", line 407, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', error(10060, 'A con
nection attempt failed because the connected party did not properly respond afte
r a period of time, or established connection failed because connected host has
failed to respond'))
根据10060
错误消息判断我认为连接超时,所以我建议用户在put调用中添加timeout=None
参数,但这似乎没有解决这个问题。
对于接下来要尝试的内容有什么建议吗?