From 1f99e532eb103dc8ba3c4fe7dd05dc4b2bfe475d Mon Sep 17 00:00:00 2001 From: tiedu Date: Thu, 11 Jan 2018 22:04:54 +0800 Subject: [PATCH] Fix some bug in thread upload --- qcloud_cos/cos_client.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/qcloud_cos/cos_client.py b/qcloud_cos/cos_client.py index d48e51c9..b0adb1e0 100644 --- a/qcloud_cos/cos_client.py +++ b/qcloud_cos/cos_client.py @@ -1279,6 +1279,9 @@ def upload_file(self, Bucket, Key, LocalFilePath, PartSize=10, MAXThread=5, **kw offset += part_size pool.wait_completion() + result = pool.get_result() + if not result['success_all']: + raise CosClientError('some upload_part fail after max_retry') lst = sorted(lst, key=lambda x: x['PartNumber']) # 按PartNumber升序排列 # 完成分片上传 @@ -1385,6 +1388,10 @@ def copy(self, Bucket, Key, CopySource, CopyStatus='Copy', PartSize=10, MAXThrea offset += part_size pool.wait_completion() + result = pool.get_result() + if not result['success_all']: + raise CosClientError('some upload_part_copy fail after max_retry') + lst = sorted(lst, key=lambda x: x['PartNumber']) # 按PartNumber升序排列 # 完成分片上传 try: @@ -1450,6 +1457,9 @@ def upload_file_from_buffer(self, Bucket, Key, Body, MaxBufferSize=100, PartSize data = Body.read(part_size) pool.wait_completion() + result = pool.get_result() + if not result['success_all']: + raise CosClientError('some upload_part fail after max_retry') lst = sorted(lst, key=lambda x: x['PartNumber']) # 按PartNumber升序排列 # 完成分片上传