Skip to content

Commit 82311db

Browse files
authored
Merge pull request #264 from wolf-joe/master
feat: catch potential io exception
2 parents eac5253 + 189b460 commit 82311db

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

qcloud_cos/cos_client.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,10 @@ def send_request(self, method, url, bucket, timeout=30, cos_request=True, ci_req
366366
if 'data' in kwargs:
367367
body = kwargs['data']
368368
if hasattr(body, 'tell') and hasattr(body, 'seek') and hasattr(body, 'read'):
369-
file_position = body.tell() # 记录文件当前位置
369+
try:
370+
file_position = body.tell() # 记录文件当前位置
371+
except Exception as ioe:
372+
file_position = None
370373
kwargs['data'] = to_bytes(kwargs['data'])
371374
if self._conf._ip is not None and self._conf._scheme == 'https':
372375
kwargs['verify'] = False

0 commit comments

Comments
 (0)