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: do not import pydrive2 on module load #3399

Merged
merged 1 commit into from
Feb 25, 2020
Merged
Changes from all commits
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
10 changes: 6 additions & 4 deletions dvc/remote/gdrive.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,18 @@ def __init__(self, path):


def gdrive_retry(func):
from pydrive2.files import ApiRequestError

retry_re = re.compile(r"HttpError (403|500|502|503|504)")

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

return isinstance(exc, ApiRequestError) and retry_re.search(str(exc))

# 15 tries, start at 0.5s, multiply by golden ratio, cap at 20s
return retry(
15,
timeout=lambda a: min(0.5 * 1.618 ** a, 20),
errors=ApiRequestError,
filter_errors=lambda exc: retry_re.search(str(exc)),
filter_errors=should_retry,
)(func)


Expand Down