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:39 UTC

[beam] branch aaltay-patch-1 created (now f1a6e06)

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

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


      at f1a6e06  Add a timeout to urlopen calls

This branch includes the following new commits:

     new f1a6e06  Add a timeout to urlopen calls

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



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

Posted by al...@apache.org.
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']))