Skip to content

Commit c020e50

Browse files
authored
Add shorter timeout for GCP util. (#4762)
* Add shorter timeout for GCP util. * Add comment for change reason and unit for timeout.
1 parent 70b176a commit c020e50

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

official/utils/logs/cloud_lib.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@
2525
def on_gcp():
2626
"""Detect whether the current running environment is on GCP."""
2727
try:
28-
response = requests.get(GCP_METADATA_URL, headers=GCP_METADATA_HEADER)
28+
# 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)
2932
return response.status_code == 200
3033
except requests.exceptions.RequestException:
3134
return False

0 commit comments

Comments
 (0)