Skip to content
This repository has been archived by the owner on Feb 2, 2022. It is now read-only.

Add retry mechanism to fetch_text #85

Merged
merged 1 commit into from
Apr 19, 2019

Conversation

rgreinho
Copy link
Member

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Description

Sometimes the fetch_text function does not succeed to retrieve data
and makes ScrAPD crash. This patch adds a retry mechanism to this
function, with exponential backoff, and simply raises a ValueError
exception if it really cannot retrieve any data.

Checklist:

  • [] I have updated the documentation accordingly
  • [] I have written unit tests

Fixes #83

@rgreinho rgreinho self-assigned this Apr 19, 2019
@rgreinho rgreinho requested a review from mrengler April 19, 2019 00:30
@rgreinho rgreinho force-pushed the issues/83/fecth-page-retry branch 3 times, most recently from 3d234b2 to a4a4f24 Compare April 19, 2019 02:23
Sometimes the `fetch_text` function does not succeed to retrieve data
and makes ScrAPD crash. This patch adds a retry mechanism to this
function, with exponential backoff, and simply raises a `ValueError`
exception if it really cannot retrieve any data.

Fixes scrapd#83
@@ -15,6 +18,7 @@
PAGE_DETAILS_URL = 'http://austintexas.gov/'


@retry(stop=stop_after_attempt(3), wait=wait_exponential(multiplier=1, min=4, max=10))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have we seen any examples of >3 failures? I'm not sure how rare it is but that seems safe to me.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have not because it currently fails at the first one. If we see more failures, I'll readjust the parameters (more retries, more wait).

Copy link
Contributor

@mrengler mrengler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Retry functionality and tests look good to me, and tests / formatting passes.

@mergify mergify bot merged commit 10b0187 into scrapd:master Apr 19, 2019
@rgreinho rgreinho deleted the issues/83/fecth-page-retry branch April 21, 2019 20:43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ScrAPD fails when no data is retrieved
2 participants