[go: up one dir, main page]

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

How to handle backoff on Facebook cursor? #192

Open
vladaman opened this issue Jan 24, 2023 · 1 comment
Open

How to handle backoff on Facebook cursor? #192

vladaman opened this issue Jan 24, 2023 · 1 comment

Comments

@vladaman
Copy link
vladaman commented Jan 24, 2023

We're using Facebook Marketing API and we'd like to backoff when we iterate over cursor. Cursor actually fetches pages from API.

@backoff.on_exception(backoff.expo, FacebookRequestError, max_tries=8, max_value=300)
def fetch_ad_sets(my_account, fields, params):
    return my_account.get_ad_sets(
        fields=fields,
        params=params
    )

adsets_cursor: Cursor = fetch_ad_sets(my_account, fields, params)
# may throw an exception
for ad_set_record in adsets_cursor:
    # do work

Is there any way to handle this with backoff ?

@bhashithe-air
Copy link

I think you can simply wrap it with a function which is decorated with the proper exception, for example:

@backoff.on_exception(backoff.expo, FacebookRequestError, max_tries=8, max_value=300)
def fetch_ad_sets_wrapper(my_account, fields, params):
    return fetch_ad_sets(my_account, fields, params)

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

No branches or pull requests

2 participants