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(