Skip to content

Commit

Permalink
Merge pull request #115 from lewzylu/patch-4xx-retry
Browse files Browse the repository at this point in the history
Fix 400 retry
  • Loading branch information
lewzylu authored Apr 24, 2020
2 parents 00f3b2a + ca0d8c1 commit c05f1a9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.pyc
4 changes: 3 additions & 1 deletion qcloud_cos/cos_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,10 @@ def send_request(self, method, url, bucket, timeout=30, **kwargs):
res = self._session.delete(url, timeout=timeout, proxies=self._conf._proxies, **kwargs)
elif method == 'HEAD':
res = self._session.head(url, timeout=timeout, proxies=self._conf._proxies, **kwargs)
if res.status_code < 500: # 2xx和3xx都认为是成功的, 4xx不重试
if res.status_code < 400: # 2xx和3xx都认为是成功的
return res
elif res.status_code < 500: # 4xx 不重试
break
except Exception as e: # 捕获requests抛出的如timeout等客户端错误,转化为客户端错误
logger.exception('url:%s, retry_time:%d exception:%s' % (url, j, str(e)))
if j < self._retry:
Expand Down

0 comments on commit c05f1a9

Please sign in to comment.