trap requests timeout error (#1607)
This commit is contained in:
parent
46af8b7956
commit
91f71fef68
|
@ -29,6 +29,7 @@ import warnings
|
||||||
|
|
||||||
import click
|
import click
|
||||||
import google.auth
|
import google.auth
|
||||||
|
import requests.exceptions
|
||||||
|
|
||||||
from google.auth.transport.requests import AuthorizedSession
|
from google.auth.transport.requests import AuthorizedSession
|
||||||
|
|
||||||
|
@ -123,7 +124,8 @@ def fetch(request, delete=False):
|
||||||
else:
|
else:
|
||||||
response = HTTP.post(request.url, headers=request.headers,
|
response = HTTP.post(request.url, headers=request.headers,
|
||||||
data=json.dumps(request.data))
|
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])
|
raise SystemExit(e.args[0])
|
||||||
try:
|
try:
|
||||||
rdata = json.loads(response.content)
|
rdata = json.loads(response.content)
|
||||||
|
|
|
@ -2,3 +2,4 @@ click
|
||||||
functions-framework
|
functions-framework
|
||||||
google-api-core
|
google-api-core
|
||||||
google-cloud-monitoring
|
google-cloud-monitoring
|
||||||
|
requests
|
Loading…
Reference in New Issue