好友
阅读权限10
听众
最后登录1970-1-1
|
def _request(self, task, entry, method, url, **kwargs):
try:
return task.requests.request(method, url, **kwargs)
except Exception as e:
if url in [entry['url'], entry['base_url']]:
entry['result'] = SignState.NETWORK_ERROR.value.format(str(e))
else:
entry['messages'] = SignState.NETWORK_ERROR.value.format(str(e))
return None
我已经这样捕获Exception了 为什么有时候还是会出现
File "/root/.flexget/config/plugins/auto_sign_in.py", line 256, in check_state
content = self._decode(response, (entry['encoding']))
| | | -> <Entry(title=haIDAn 2020-04-19,state=accepted)>
| | -> <Response [200]>
| -> <function PluginAutoSignIn._decode at 0x7f172ddadc10>
-> <flexget.plugins.auto_sign_in.PluginAutoSignIn object at 0x7f172dd29340>
File "/root/.flexget/config/plugins/auto_sign_in.py", line 280, in _decode
content = gzip.decompress(response.content)
| | | -> <property object at 0x7f172ed9a1d0>
| | -> <Response [200]>
| -> <function decompress at 0x7f172df559d0>
-> <module 'gzip' from '/usr/local/lib/python3.8/gzip.py'>
File "/usr/local/lib/python3.8/site-packages/requests/models.py", line 828, in content
self._content = b''.join(self.iter_content(CONTENT_CHUNK_SIZE)) or b''
| | | | -> 10240
| | | -> <function Response.iter_content at 0x7f172ed9b550>
| | -> <Response [200]>
| -> False
-> <Response [200]>
File "/usr/local/lib/python3.8/site-packages/requests/models.py", line 757, in generate
raise ConnectionError(e)
-> <class 'requests.exceptions.ConnectionError'>
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='www.haidan.cc', port=443): Read timed out.
我该如何正确的捕获这个异常?
|
|
发帖前要善用【论坛搜索】功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。 |
|
|
|
|