cobweb-launcher 3.1.37__py3-none-any.whl → 3.1.38__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cobweb/base/request.py +26 -23
- {cobweb_launcher-3.1.37.dist-info → cobweb_launcher-3.1.38.dist-info}/METADATA +1 -1
- {cobweb_launcher-3.1.37.dist-info → cobweb_launcher-3.1.38.dist-info}/RECORD +6 -6
- {cobweb_launcher-3.1.37.dist-info → cobweb_launcher-3.1.38.dist-info}/LICENSE +0 -0
- {cobweb_launcher-3.1.37.dist-info → cobweb_launcher-3.1.38.dist-info}/WHEEL +0 -0
- {cobweb_launcher-3.1.37.dist-info → cobweb_launcher-3.1.38.dist-info}/top_level.txt +0 -0
cobweb/base/request.py
CHANGED
@@ -488,35 +488,38 @@ class Request:
|
|
488
488
|
_start = downloaded
|
489
489
|
_end = min(downloaded + chunk_size - 1, self.content_length - 1)
|
490
490
|
detect_settings.setdefault("headers", {})['Range'] = f"bytes={_start}-{_end}"
|
491
|
+
try:
|
491
492
|
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
)
|
497
|
-
|
498
|
-
if self.response.status_code == 206:
|
499
|
-
chunk_data = self.response.content
|
500
|
-
yield chunk_data
|
501
|
-
downloaded += len(chunk_data)
|
502
|
-
retry_count = 0 # 重置重试计数
|
503
|
-
self._log_download_progress(
|
504
|
-
start_time=start_time,
|
505
|
-
downloaded=downloaded
|
493
|
+
self.response = requests.request(
|
494
|
+
method=self.method,
|
495
|
+
url=self.url,
|
496
|
+
**detect_settings
|
506
497
|
)
|
507
|
-
elif self.response.status_code == 416: # Range Not Satisfiable
|
508
|
-
logging.info("Range请求超出范围")
|
509
|
-
break
|
510
498
|
|
511
|
-
|
512
|
-
|
499
|
+
if self.response.status_code == 206:
|
500
|
+
chunk_data = self.response.content
|
501
|
+
yield chunk_data
|
502
|
+
downloaded += len(chunk_data)
|
503
|
+
retry_count = 0 # 重置重试计数
|
504
|
+
self._log_download_progress(
|
505
|
+
start_time=start_time,
|
506
|
+
downloaded=downloaded
|
507
|
+
)
|
508
|
+
elif self.response.status_code == 416: # Range Not Satisfiable
|
509
|
+
logging.info("Range请求超出范围")
|
510
|
+
break
|
511
|
+
|
512
|
+
except Exception as e:
|
513
|
+
logging.exception(f"请求失败 - URL: {self.url}, 错误: {e}, 当前重试次数: {retry_count}")
|
514
|
+
finally:
|
515
|
+
self.response.close()
|
516
|
+
self.response = None
|
513
517
|
if retry_count < max_retries:
|
518
|
+
time.sleep(0.5 * retry_count)
|
514
519
|
retry_count += 1
|
515
|
-
time.sleep(0.5)
|
516
520
|
continue
|
517
|
-
|
518
|
-
|
519
|
-
self.response = None
|
521
|
+
else:
|
522
|
+
raise ValueError(f"超过当前最大重试次数,请求失败!当前重试次数: {retry_count}")
|
520
523
|
|
521
524
|
def detect_accept_ranges(self) -> bool:
|
522
525
|
detect_settings = self.request_settings.copy()
|
@@ -5,7 +5,7 @@ cobweb/base/__init__.py,sha256=NanSxJr0WsqjqCNOQAlxlkt-vQEsERHYBzacFC057oI,222
|
|
5
5
|
cobweb/base/common_queue.py,sha256=hYdaM70KrWjvACuLKaGhkI2VqFCnd87NVvWzmnfIg8Q,1423
|
6
6
|
cobweb/base/item.py,sha256=1bS4U_3vzI2jzSSeoEbLoLT_5CfgLPopWiEYtaahbvw,1674
|
7
7
|
cobweb/base/logger.py,sha256=Vsg1bD4LXW91VgY-ANsmaUu-mD88hU_WS83f7jX3qF8,2011
|
8
|
-
cobweb/base/request.py,sha256=
|
8
|
+
cobweb/base/request.py,sha256=TQgXiQvV3QGJTpUcoxpaEAg2aC_pTwCgNTc7DWSliG8,22111
|
9
9
|
cobweb/base/response.py,sha256=L3sX2PskV744uz3BJ8xMuAoAfGCeh20w8h0Cnd9vLo0,11377
|
10
10
|
cobweb/base/seed.py,sha256=ddaWCq_KaWwpmPl1CToJlfCxEEnoJ16kjo6azJs9uls,5000
|
11
11
|
cobweb/base/task_queue.py,sha256=2MqGpHGNmK5B-kqv7z420RWyihzB9zgDHJUiLsmtzOI,6402
|
@@ -34,8 +34,8 @@ cobweb/utils/decorators.py,sha256=ZwVQlz-lYHgXgKf9KRCp15EWPzTDdhoikYUNUCIqNeM,11
|
|
34
34
|
cobweb/utils/dotting.py,sha256=L-jGSApdnFIP4jUWH6p5qIme0aJ1vyDrxAx8wOJWvcs,1960
|
35
35
|
cobweb/utils/oss.py,sha256=wmToIIVNO8nCQVRmreVaZejk01aCWS35e1NV6cr0yGI,4192
|
36
36
|
cobweb/utils/tools.py,sha256=14TCedqt07m4z6bCnFAsITOFixeGr8V3aOKk--L7Cr0,879
|
37
|
-
cobweb_launcher-3.1.
|
38
|
-
cobweb_launcher-3.1.
|
39
|
-
cobweb_launcher-3.1.
|
40
|
-
cobweb_launcher-3.1.
|
41
|
-
cobweb_launcher-3.1.
|
37
|
+
cobweb_launcher-3.1.38.dist-info/LICENSE,sha256=z1rxSIGOyzcSb3orZxFPxzx-0C1vTocmswqBNxpKfEk,1063
|
38
|
+
cobweb_launcher-3.1.38.dist-info/METADATA,sha256=NKJtHSfd5l5tmKedjsFsweW-U5c0yx4Qtm3_u3VLTa8,6051
|
39
|
+
cobweb_launcher-3.1.38.dist-info/WHEEL,sha256=ewwEueio1C2XeHTvT17n8dZUJgOvyCWCt0WVNLClP9o,92
|
40
|
+
cobweb_launcher-3.1.38.dist-info/top_level.txt,sha256=4GETBGNsKqiCUezmT-mJn7tjhcDlu7nLIV5gGgHBW4I,7
|
41
|
+
cobweb_launcher-3.1.38.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|