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

gdrive: remove redundant _gdrive_retry function #6831

Merged
merged 2 commits into from
Oct 18, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions dvc/fs/gdrive.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,36 +34,6 @@ def __init__(self, cred_location):
super().__init__(message)


def _gdrive_retry(func):
def should_retry(exc):
from pydrive2.files import ApiRequestError

if not isinstance(exc, ApiRequestError):
return False

error_code = exc.error.get("code", 0)
result = False
if 500 <= error_code < 600:
result = True

if error_code == 403:
result = exc.GetField("reason") in [
"userRateLimitExceeded",
"rateLimitExceeded",
]
if result:
logger.debug(f"Retrying GDrive API call, error: {exc}.")

return result

# 16 tries, start at 0.5s, multiply by golden ratio, cap at 20s
return retry(
16,
timeout=lambda a: min(0.5 * 1.618 ** a, 20),
filter_errors=should_retry,
)(func)


class GDriveURLInfo(CloudURLInfo):
def __init__(self, url):
super().__init__(url)
Expand Down