You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by al...@apache.org on 2019/06/21 16:59:40 UTC

[beam] 01/01: Add a timeout to urlopen calls

This is an automated email from the ASF dual-hosted git repository.

altay pushed a commit to branch aaltay-patch-1
in repository https://gitbox.apache.org/repos/asf/beam.git

commit f1a6e06eac1789a2b859edeaece6d4fdf080e5db
Author: Ahmet Altay <aa...@gmail.com>
AuthorDate: Fri Jun 21 09:59:18 2019 -0700

    Add a timeout to urlopen calls
---
 sdks/python/apache_beam/internal/gcp/auth.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sdks/python/apache_beam/internal/gcp/auth.py b/sdks/python/apache_beam/internal/gcp/auth.py
index 1c6d8e2..8b331e8 100644
--- a/sdks/python/apache_beam/internal/gcp/auth.py
+++ b/sdks/python/apache_beam/internal/gcp/auth.py
@@ -93,7 +93,7 @@ class _GCEMetadataCredentials(OAuth2Credentials):
     token_url = ('http://{}/computeMetadata/v1/instance/service-accounts/'
                  'default/token').format(metadata_root)
     req = Request(token_url, headers={'Metadata-Flavor': 'Google'})
-    token_data = json.loads(urlopen(req).read().decode('utf-8'))
+    token_data = json.loads(urlopen(req, timeout=60).read().decode('utf-8'))
     self.access_token = token_data['access_token']
     self.token_expiry = (refresh_time +
                          datetime.timedelta(seconds=token_data['expires_in']))