We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 70b176a commit c020e50Copy full SHA for c020e50
official/utils/logs/cloud_lib.py
@@ -25,7 +25,10 @@
25
def on_gcp():
26
"""Detect whether the current running environment is on GCP."""
27
try:
28
- response = requests.get(GCP_METADATA_URL, headers=GCP_METADATA_HEADER)
+ # Timeout in 5 seconds, in case the test environment has connectivity issue.
29
+ # There is not default timeout, which means it might block forever.
30
+ response = requests.get(
31
+ GCP_METADATA_URL, headers=GCP_METADATA_HEADER, timeout=5)
32
return response.status_code == 200
33
except requests.exceptions.RequestException:
34
return False
0 commit comments