Skip to content

Commit 189b460

Browse files
authored
feat: catch potential io exception
1 parent 6e0837a commit 189b460

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
@@ -353,7 +353,10 @@ def send_request(self, method, url, bucket, timeout=30, cos_request=True, ci_req
353353
if 'data' in kwargs:
354354
body = kwargs['data']
355355
if hasattr(body, 'tell') and hasattr(body, 'seek') and hasattr(body, 'read'):
356-
file_position = body.tell() # 记录文件当前位置
356+
try:
357+
file_position = body.tell() # 记录文件当前位置
358+
except Exception as ioe:
359+
file_position = None
357360
kwargs['data'] = to_bytes(kwargs['data'])
358361
if self._conf._ip is not None and self._conf._scheme == 'https':
359362
kwargs['verify'] = False

0 commit comments

Comments
 (0)