Skip to content

Commit

Permalink
gdrive: do not import pydrive2 on module load (#3399)
Browse files Browse the repository at this point in the history
  • Loading branch information
Suor authored Feb 25, 2020
1 parent 8d04d6d commit a81ab5e
Showing 1 changed file with 6 additions and 4 deletions.
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

0 comments on commit a81ab5e

Please sign in to comment.