From 2864ebc7a52832f0fda3820d6aeb8723c0d09597 Mon Sep 17 00:00:00 2001 From: Craig Citro Date: Fri, 9 Jan 2015 13:35:51 -0800 Subject: [PATCH] Bump GCE detection timeout to 1 sec. --- oauth2client/client.py | 2 +- tests/test_oauth2client.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/oauth2client/client.py b/oauth2client/client.py index 5432c82..9ebbcbf 100644 --- a/oauth2client/client.py +++ b/oauth2client/client.py @@ -938,7 +938,7 @@ def _detect_gce_environment(urlopen=None): # the metadata resolution was particularly slow. The latter case is # "unlikely". try: - response = urlopen('http://169.254.169.254/', timeout=0.1) + response = urlopen('http://169.254.169.254/', timeout=1) return response.info().get('Metadata-Flavor', '') == 'Google' except socket.timeout: logger.info('Timeout attempting to reach GCE metadata service.') diff --git a/tests/test_oauth2client.py b/tests/test_oauth2client.py index aa3f068..fb44de4 100644 --- a/tests/test_oauth2client.py +++ b/tests/test_oauth2client.py @@ -215,7 +215,7 @@ class GoogleCredentialsTests(unittest.TestCase): autospec=True) as urlopen: self.assertEqual('GCE_PRODUCTION', _get_environment()) urlopen.assert_called_once_with( - 'http://169.254.169.254/', timeout=0.1) + 'http://169.254.169.254/', timeout=1) def test_get_environment_unknown(self): os.environ['SERVER_SOFTWARE'] = '' @@ -224,7 +224,7 @@ class GoogleCredentialsTests(unittest.TestCase): autospec=True) as urlopen: self.assertEqual(DEFAULT_ENV_NAME, _get_environment()) urlopen.assert_called_once_with( - 'http://169.254.169.254/', timeout=0.1) + 'http://169.254.169.254/', timeout=1) def test_get_environment_variable_file(self): environment_variable_file = datafile(