Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/retry insights job polling #174

Merged
merged 8 commits into from
Nov 2, 2021

Conversation

dsprayberry
Copy link
Contributor

@dsprayberry dsprayberry commented Nov 1, 2021

Description of change

Adds sleep and retry to job polling. Creates new tests for consistent failure / retry and failure / eventual success.

Manual QA steps

  • wrote script to reproduce failure scenario and exit upon successful retry
  • validated locally
  • new tests added

Risks

  • minimally extended job duration

Rollback steps

  • revert this branch

Copy link
Contributor

@dmosorast dmosorast left a comment

Choose a reason for hiding this comment

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

I think this might need a bit of a redesign to get a proper retry pattern set up.

tap_facebook/__init__.py Outdated Show resolved Hide resolved
def api_get_with_retry(job):
job = job.api_get()
return job

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd move this closer to usage inside the class and mark it "private" in the python sense by prefixing with __.

Pylint will probably warn about no self usage, but I think you can use @staticmethod to stop that. So like:

@staticmethod
@retry_pattern(backoff.constant, FacebookRequestError, max_tries=5, interval=1)
def __api_get_with_retry(job):
    job = job.api_get()
    return job

Then the usage would be

AdsInsights.__api_get_with_retry(job)

Copy link
Contributor

Choose a reason for hiding this comment

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

The benefit of this is that it makes it clear that this is only for insights usage and to keep it localized for if we want to refactor the class into its own module.

@dsprayberry dsprayberry merged commit 10bad1c into master Nov 2, 2021
@dsprayberry dsprayberry deleted the feature/retry-insights-job-polling branch November 2, 2021 17:35
jesuejunior pushed a commit to sixcodes/tap-facebook that referenced this pull request Mar 17, 2023
* Add sleep and retry for insights job polling

* correct dylans typo

* added tests, got tests passing

* Makes api_get_with_retry function that uses retry wrapper

* Style changes

* Style changes 2

* Version Bump

* removed count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants