googleads / googleads/googleads-python-lib

Improve Ad Manager's WaitForReport polling mechanism

Open
#465 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
749
Forks
967
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in googleads/ad_manager.py at AdManager's WaitForReport method, especially the time.sleep(30) call and the version-specific status checks. Review the existing polling flow and determine the expected backoff behavior; done means report polling still reaches the COMPLETED or FAILED state while using increasing delays.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.