Skip to content

Commit

Permalink
fix: retry only with 404
Browse files Browse the repository at this point in the history
  • Loading branch information
pcrespov committed Dec 1, 2022
1 parent be939e3 commit 6d5cf24
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tests/public-api/test_solvers_jobs_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from osparc.models import File, Job, JobInputs, JobOutputs, JobStatus, Solver
from tenacity import Retrying, TryAgain
from tenacity.after import after_log
from tenacity.retry import retry_if_exception_type
from tenacity.stop import stop_after_attempt
from tenacity.wait import wait_fixed

Expand Down Expand Up @@ -179,10 +180,12 @@ def test_create_job(


_RETRY_POLICY_IF_LOGFILE_NOT_FOUND = dict(
reraise=True,
# only 404 are retried, the rest are failures
retry=retry_if_exception_type(TryAgain),
wait=wait_fixed(1),
stop=stop_after_attempt(5),
after=after_log(logger, logging.WARNING),
reraise=True,
)


Expand Down Expand Up @@ -283,8 +286,8 @@ def test_run_job(
print("Testing output logfile ...")

# NOTE: https://github.com/itisfoundation/osparc-simcore/issues/3569 shows
# that this test might not have the logs ready in time and returns a 404
# for that reason we make a retry
# that this test might not have the logs ready in time and returns a 404 (not found)
# for that reason we do a few retries before giving up
for attempt in Retrying(_RETRY_POLICY_IF_LOGFILE_NOT_FOUND):
with attempt:
try:
Expand Down

0 comments on commit 6d5cf24

Please sign in to comment.