Skip to content

Commit 96f07dc

Browse files
committed
fix bug
1 parent ee23b30 commit 96f07dc

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

qcloud_cos/cos_client.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from requests import Request, Session
1515
from datetime import datetime
1616
from six.moves.urllib.parse import quote, unquote, urlencode
17+
from six import text_type, binary_type
1718
from hashlib import md5
1819
from dicttoxml import dicttoxml
1920
from .streambody import StreamBody
@@ -266,7 +267,15 @@ def send_request(self, method, url, bucket, timeout=30, cos_request=True, **kwar
266267
break
267268
except Exception as e: # 捕获requests抛出的如timeout等客户端错误,转化为客户端错误
268269
logger.exception('url:%s, retry_time:%d exception:%s' % (url, j, str(e)))
269-
if j < self._retry:
270+
can_retry = False
271+
if 'data' in kwargs:
272+
body = kwargs[data]
273+
if hasattr(body, 'tell') and hasattr(body, 'seek') and hasattr(body, 'read'):
274+
can_retry = True
275+
elif isinstance(body, unicode) or isinstance(body, text_type) or isinstance(body, binary_type):
276+
can_retry = True
277+
278+
if j < self._retry and can_retry:
270279
if file_position is not None:
271280
try:
272281
kwargs['data'].seek(file_position)

0 commit comments

Comments
 (0)