trap requests timeout error (#1607)

This commit is contained in:
Ludovico Magnocavallo 2023-08-21 18:37:54 +02:00 committed by GitHub
parent 46af8b7956
commit 91f71fef68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View File

@ -29,6 +29,7 @@ import warnings
import click
import google.auth
import requests.exceptions
from google.auth.transport.requests import AuthorizedSession
@ -123,7 +124,8 @@ def fetch(request, delete=False):
else:
response = HTTP.post(request.url, headers=request.headers,
data=json.dumps(request.data))
except google.auth.exceptions.RefreshError as e:
except (google.auth.exceptions.RefreshError,
requests.exceptions.ReadTimeout) as e:
raise SystemExit(e.args[0])
try:
rdata = json.loads(response.content)

View File

@ -2,3 +2,4 @@ click
functions-framework
google-api-core
google-cloud-monitoring
requests