scrapely-client-python 1.0.10__py3-none-any.whl → 1.0.11__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.
- scrapely_client/http_clients/_impit.py +18 -2
- {scrapely_client_python-1.0.10.dist-info → scrapely_client_python-1.0.11.dist-info}/METADATA +1 -1
- {scrapely_client_python-1.0.10.dist-info → scrapely_client_python-1.0.11.dist-info}/RECORD +6 -6
- {scrapely_client_python-1.0.10.dist-info → scrapely_client_python-1.0.11.dist-info}/WHEEL +0 -0
- {scrapely_client_python-1.0.10.dist-info → scrapely_client_python-1.0.11.dist-info}/licenses/LICENSE +0 -0
- {scrapely_client_python-1.0.10.dist-info → scrapely_client_python-1.0.11.dist-info}/licenses/NOTICE +0 -0
|
@@ -86,6 +86,22 @@ _STORAGE_COLLECTION_PATH_RE = re.compile(r'/(?:datasets|key-value-stores|request
|
|
|
86
86
|
# so resending can't apply it twice.
|
|
87
87
|
_NOT_APPLIED_STATUS_CODES = frozenset({HTTPStatus.BAD_GATEWAY, HTTPStatus.SERVICE_UNAVAILABLE})
|
|
88
88
|
|
|
89
|
+
# The API answers its own 502/504 as 503 with the original in this header, so the edge (Cloudflare) keeps the
|
|
90
|
+
# error body. Retry decisions use the original: a 504 (e.g. a Standby container timeout) may have been applied.
|
|
91
|
+
_ORIGINAL_STATUS_HEADER = 'x-scrapely-status'
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def _effective_status(response: Any) -> int:
|
|
95
|
+
"""The status to act on: the original 502/504 of a 503 that carries X-Scrapely-Status, else the HTTP status."""
|
|
96
|
+
status = response.status_code
|
|
97
|
+
if status != HTTPStatus.SERVICE_UNAVAILABLE:
|
|
98
|
+
return status
|
|
99
|
+
try:
|
|
100
|
+
original = int((response.headers or {}).get(_ORIGINAL_STATUS_HEADER) or 0)
|
|
101
|
+
except (TypeError, ValueError):
|
|
102
|
+
return status
|
|
103
|
+
return original if original in (HTTPStatus.BAD_GATEWAY, HTTPStatus.GATEWAY_TIMEOUT) else status
|
|
104
|
+
|
|
89
105
|
# Keyed requests: the first request with the key is still being applied, so a resend gets its answer shortly.
|
|
90
106
|
_KEY_IN_PROGRESS_ERROR_TYPE = 'idempotency-key-in-progress'
|
|
91
107
|
# Keyed requests: the server can't tell whether the first request was applied, and no resend changes that.
|
|
@@ -312,7 +328,7 @@ class ImpitHttpClient(HttpClient):
|
|
|
312
328
|
stop_retrying()
|
|
313
329
|
elif (
|
|
314
330
|
response.status_code != HTTPStatus.TOO_MANY_REQUESTS
|
|
315
|
-
and response
|
|
331
|
+
and _effective_status(response) not in _NOT_APPLIED_STATUS_CODES
|
|
316
332
|
and _is_unsafe_to_resend(method, url, headers, params)
|
|
317
333
|
):
|
|
318
334
|
logger.debug(
|
|
@@ -605,7 +621,7 @@ class ImpitHttpClientAsync(HttpClientAsync):
|
|
|
605
621
|
stop_retrying()
|
|
606
622
|
elif (
|
|
607
623
|
response.status_code != HTTPStatus.TOO_MANY_REQUESTS
|
|
608
|
-
and response
|
|
624
|
+
and _effective_status(response) not in _NOT_APPLIED_STATUS_CODES
|
|
609
625
|
and _is_unsafe_to_resend(method, url, headers, params)
|
|
610
626
|
):
|
|
611
627
|
logger.debug(
|
|
@@ -53,7 +53,7 @@ scrapely_client/_utils/try_import.py,sha256=T1m3vcn6V6crHwm4Syw8X_TwcKfhfv_shWZD
|
|
|
53
53
|
scrapely_client/errors.py,sha256=sNKvkA7KUjLfBPrCkhrFu6Owt9cBKfCOL5Olw0IhjnQ,6955
|
|
54
54
|
scrapely_client/http_clients/__init__.py,sha256=s6d7wVMJKLWodAfGR3lPAXfy4aEF1RWQgHKB1OMR9tY,396
|
|
55
55
|
scrapely_client/http_clients/_base.py,sha256=5babUECMpMiU-OMy7J_-LNqQxQ2wERERw8YuRuy9Vvg,19011
|
|
56
|
-
scrapely_client/http_clients/_impit.py,sha256=
|
|
56
|
+
scrapely_client/http_clients/_impit.py,sha256=757B2KNU9QYtyD9C7u3bZdmbSruM0pluHXkI45tWKWo,30058
|
|
57
57
|
scrapely_client/http_compressors/__init__.py,sha256=2n7Ym-q5axJda90TjsdDwkniB_KQzPwjrCjqTwk7nW8,1104
|
|
58
58
|
scrapely_client/http_compressors/_base.py,sha256=25W0zDO54qdSnhYLvYyF4EbYM2mh5gxwlaaQ5yKAuzw,672
|
|
59
59
|
scrapely_client/http_compressors/_brotli.py,sha256=ItLG3DgHqH3dbyAyQUcRrTPaJgxwCk-C6OL7exGWb0s,1294
|
|
@@ -61,8 +61,8 @@ scrapely_client/http_compressors/_gzip.py,sha256=IJHZ87B5L1nrnXNFf1PjsYf-1MIIp9G
|
|
|
61
61
|
scrapely_client/http_compressors/_resolve.py,sha256=AfIUzwX-ExczMgMQNAhfPd4CKAVKhIGq697bUm9i62k,1653
|
|
62
62
|
scrapely_client/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
63
63
|
scrapely_client/types.py,sha256=Wnb9-GBN6OcQGfiDk18TJjIzvHXb5MHrjJaIce-2UzY,2215
|
|
64
|
-
scrapely_client_python-1.0.
|
|
65
|
-
scrapely_client_python-1.0.
|
|
66
|
-
scrapely_client_python-1.0.
|
|
67
|
-
scrapely_client_python-1.0.
|
|
68
|
-
scrapely_client_python-1.0.
|
|
64
|
+
scrapely_client_python-1.0.11.dist-info/licenses/LICENSE,sha256=AsFjHssKjj4LGd2ZCqXn6FBzMqcWdjQre1byPPSypVw,11355
|
|
65
|
+
scrapely_client_python-1.0.11.dist-info/licenses/NOTICE,sha256=0Seguz6wGdTod6Rld--Q4nHcmVqZF56Q_Atbh4YFEts,337
|
|
66
|
+
scrapely_client_python-1.0.11.dist-info/WHEEL,sha256=MWx7psoF7KNST9G72pGtiBYuaXRXQXBk9pw5R6FzYko,80
|
|
67
|
+
scrapely_client_python-1.0.11.dist-info/METADATA,sha256=hJNA_61p6d-r91PHd5PUvbNZ6UDUE8gmUxko015iMZY,12419
|
|
68
|
+
scrapely_client_python-1.0.11.dist-info/RECORD,,
|
|
File without changes
|
{scrapely_client_python-1.0.10.dist-info → scrapely_client_python-1.0.11.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
{scrapely_client_python-1.0.10.dist-info → scrapely_client_python-1.0.11.dist-info}/licenses/NOTICE
RENAMED
|
File without changes
|