Skip to content

Commit

Permalink
export: fix handling of 504 Gateway Time-out
Browse files Browse the repository at this point in the history
  • Loading branch information
karlicoss committed Nov 7, 2023
1 parent 05d4afe commit 58cd0d0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/instapexport/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# see https://github.com/rsgalloway/instapaper/issues/11
from tenacity import (
retry,
retry_if_exception_message,
retry_if_exception,
wait_exponential,
stop_after_attempt,
before_sleep_log,
Expand Down Expand Up @@ -42,7 +42,8 @@ def get_json(

# very rarely, we get one off 504 Gateway Time-out, usually retrying immediately after works
@retry(
retry=retry_if_exception_message(match='.*504 Gateway Time-out.*'),
# retry=retry_if_exception_message(match='.*504 Gateway Time-out.*') # hmm this isn't working because it can't match multiline?
retry=retry_if_exception(predicate=lambda e: '504 Gateway Time-out' in str(e)),
wait=wait_exponential(max=10),
stop=stop_after_attempt(5),
before_sleep=before_sleep_log(logger, logging.INFO),
Expand All @@ -65,6 +66,7 @@ def query_api() -> Json:
'folders': user_folders,
'bookmarks': bookmarks,
}

return query_api()


Expand Down

0 comments on commit 58cd0d0

Please sign in to comment.