Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
johanneskoester committed Mar 3, 2022
1 parent d802477 commit bf5fdfe
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions snakemake/executors/google_lifesciences.py
Expand Up @@ -24,6 +24,7 @@
from snakemake.resources import DefaultResources
import httplib2
import google_auth_httplib2

# https://github.com/googleapis/google-api-python-client/issues/299#issuecomment-343255309
logging.getLogger("googleapiclient.discovery_cache").setLevel(logging.ERROR)

Expand Down Expand Up @@ -900,26 +901,37 @@ def _retry_request(self, request, http=None, timeout=2, attempts=3):
"""
import googleapiclient
import google.auth
credentials, project_id = google.auth.default(scopes=["https://www.googleapis.com/auth/cloud-platform"])

credentials, project_id = google.auth.default(
scopes=["https://www.googleapis.com/auth/cloud-platform"]
)
if http is None:
http = google_auth_httplib2.AuthorizedHttp(credentials=credentials, http=httplib2.Http())
http = google_auth_httplib2.AuthorizedHttp(
credentials=credentials, http=httplib2.Http()
)
try:
return request.execute(http=http)
except BrokenPipeError as ex:
if attempts > 0:
time.sleep(timeout)
return self._retry_request(request, http=http, timeout=timeout * 2, attempts=attempts - 1)
return self._retry_request(
request, http=http, timeout=timeout * 2, attempts=attempts - 1
)
raise ex
except googleapiclient.errors.HttpError as ex:
if attempts > 0:
time.sleep(timeout)
return self._retry_request(request, http=http, timeout=timeout * 2, attempts=attempts - 1)
return self._retry_request(
request, http=http, timeout=timeout * 2, attempts=attempts - 1
)
log_verbose_traceback(ex)
raise ex
except Exception as ex:
if attempts > 0:
time.sleep(timeout)
return self._retry_request(request, http=http, timeout=timeout * 2, attempts=attempts - 1)
return self._retry_request(
request, http=http, timeout=timeout * 2, attempts=attempts - 1
)
log_verbose_traceback(ex)
raise ex

Expand Down

0 comments on commit bf5fdfe

Please sign in to comment.