Skip to content

Commit ea9f6ee

Browse files
committed
PR #770 exclude 500 from retry forcelist for now (#441, #764)
1 parent 2b6b3e5 commit ea9f6ee

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

openeo/utils/http.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
DEFAULT_RETRY_FORCELIST = frozenset(
2222
[
2323
429, # Too Many Requests
24-
500, # Internal Server Error
2524
502, # Bad Gateway
2625
503, # Service Unavailable
2726
504, # Gateway Timeout

tests/rest/test_job.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,7 @@
1414

1515
import openeo
1616
import openeo.rest.job
17-
from openeo.rest import (
18-
DEFAULT_JOB_STATUS_POLL_CONNECTION_RETRY_INTERVAL,
19-
JobFailedException,
20-
OpenEoApiPlainError,
21-
OpenEoClientException,
22-
)
17+
from openeo.rest import JobFailedException, OpenEoApiPlainError, OpenEoClientException
2318
from openeo.rest.job import BatchJob, ResultAsset
2419
from openeo.rest.models.general import Link
2520
from openeo.rest.models.logs import LogEntry
@@ -321,28 +316,38 @@ def test_execute_batch_with_excessive_soft_errors(con100, requests_mock, tmpdir,
321316

322317
@httpretty.activate(allow_net_connect=False)
323318
@pytest.mark.parametrize(
324-
["retry", "expectation_context", "expected_sleeps"],
319+
["retry_config", "extra_responses", "expectation_context", "expected_sleeps"],
325320
[
326321
( # Default retry settings
327322
None,
323+
[
324+
httpretty.Response(status=502, body="Bad Gateway"),
325+
httpretty.Response(status=504, body="Service Unavailable"),
326+
],
328327
contextlib.nullcontext(),
329328
[0.1, 23, 34],
330329
),
331330
(
332331
# Only retry on 429 (and fail on 500)
333332
{"status_forcelist": [429]},
333+
[
334+
httpretty.Response(status=500, body="Internal Server Error"),
335+
],
334336
pytest.raises(OpenEoApiPlainError, match=re.escape("[500] Internal Server Error")),
335-
[0.1, 23, DEFAULT_JOB_STATUS_POLL_CONNECTION_RETRY_INTERVAL],
337+
[0.1, 23],
336338
),
337339
(
338340
# No retry setup
339341
False,
342+
[],
340343
pytest.raises(OpenEoApiPlainError, match=re.escape("[429] Too Many Requests")),
341344
[0.1],
342345
),
343346
],
344347
)
345-
def test_execute_batch_retry_after_429_too_many_requests(tmpdir, retry, expectation_context, expected_sleeps):
348+
def test_execute_batch_retry_after_429_too_many_requests(
349+
tmpdir, retry_config, extra_responses, expectation_context, expected_sleeps
350+
):
346351
httpretty.register_uri(
347352
httpretty.GET,
348353
uri=API_URL + "/",
@@ -369,8 +374,9 @@ def test_execute_batch_retry_after_429_too_many_requests(tmpdir, retry, expectat
369374
httpretty.Response(body=json.dumps({"status": "queued"})),
370375
httpretty.Response(status=429, body="Too Many Requests", adding_headers={"Retry-After": "23"}),
371376
httpretty.Response(body=json.dumps({"status": "running", "progress": 80})),
372-
httpretty.Response(status=502, body="Bad Gateway"),
373-
httpretty.Response(status=500, body="Internal Server Error"),
377+
]
378+
+ extra_responses
379+
+ [
374380
httpretty.Response(body=json.dumps({"status": "running", "progress": 80})),
375381
httpretty.Response(status=429, body="Too Many Requests", adding_headers={"Retry-After": "34"}),
376382
httpretty.Response(body=json.dumps({"status": "finished", "progress": 100})),
@@ -393,7 +399,7 @@ def test_execute_batch_retry_after_429_too_many_requests(tmpdir, retry, expectat
393399
httpretty.register_uri(httpretty.GET, uri=API_URL + "/jobs/f00ba5/files/output.tiff", body="tiffdata")
394400
httpretty.register_uri(httpretty.GET, uri=API_URL + "/jobs/f00ba5/logs", body=json.dumps({"logs": []}))
395401

396-
con = openeo.connect(API_URL, retry=retry)
402+
con = openeo.connect(API_URL, retry=retry_config)
397403

398404
with mock.patch("time.sleep") as sleep_mock:
399405
job = con.load_collection("SENTINEL2").create_job()

0 commit comments

Comments
 (0)