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

Improve Ad Manager's WaitForReport polling mechanism #465

Open
svadali1 opened this issue Jun 3, 2020 · 0 comments
Open

Improve Ad Manager's WaitForReport polling mechanism #465

svadali1 opened this issue Jun 3, 2020 · 0 comments

Comments

@svadali1
Copy link

svadali1 commented Jun 3, 2020

Right now AdManager's WaitForReport waits for 30 seconds (via time.sleep(30)) if the report status is not COMPLETED or FAILED before checking the report status again.

Would it be reasonable to implement an exponential backoff strategy instead where we poll for the status of the report with an exponentially increasing delay? Something like the below seems to work:

wait_time_in_seconds = 1
exponential_backoff_multiplier = 2
...

while status != 'COMPLETED' and status != 'FAILED':
     _data_downloader_logger.debug('Report job status: %s', status)

        time.sleep(wait_time_in_seconds)

        if report_downloader._version > 'v201502':
            status = service.getReportJobStatus(report_job_id)
        else:
            status = service.getReportJob(report_job_id)['reportJobStatus']

        # Wait longer if we have to poll the report status again.
        wait_time_in_seconds *= exponential_backoff_multiplier

I will be happy to submit a PR if it makes sense to do the above change.

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

No branches or pull requests

2 participants