def git_sync_with_retries()

in script/checkout.py [0:0]


def git_sync_with_retries(max_retries=3, backoff_seconds=5):
    attempt = 0
    while True:
        try:
            print("> Running tools/git-sync-deps (attempt {}/{})".format(attempt+1, max_retries+1))
            # On Windows we need to disable HTTPS verify
            if common.host() == 'windows':
                env = os.environ.copy()
                env['PYTHONHTTPSVERIFY'] = '0'
                subprocess.check_call([sys.executable, "tools/git-sync-deps"], env=env)
            else:
                subprocess.check_call([sys.executable, "tools/git-sync-deps"])
            print("Success")
            break
        except subprocess.CalledProcessError as e:
            attempt += 1
            if attempt > max_retries:
                print("All {} retries failed. Giving up.".format(max_retries))
                raise
            else:
                wait = backoff_seconds * attempt
                print(f"Failed (exit {e.returncode}), retrying in {wait}s…")
                time.sleep(wait)