Repository: googleapis/google-auth-library-python

Issue:
GCE metadata ping taking ~75 seconds, not timing out after 3 seconds
google-api-python-client: 1.6.2
python version: 3.5.2

```
from google.auth.compute_engine import _metadata
import google.auth.transport._http_client
request = google.auth.transport._http_client.Request()
_metadata.ping(request=request)
```

When running the following script, the default timeout of 3 seconds is not used. I'm instead seeing the script complete in about 75 seconds. If I print out the value of line 4, I get `False`. I'm not sure if that indicates that the call was successful, or if a timeout had occurred. I see this take ~75 seconds consistently If I set the environment variable `GCE_METADATA_TIMEOUT` to a value such as 10, the script still takes ~75 seconds.

I'm running into this issue when using the pandas-gbq library. I'm writing a script to authorize pandas to access the gbq project. That library checks for the default google credentials, which do not exist in my case. [Here's my related issue with that library](https://github.com/pydata/pandas-gbq/issues/73).

Is this an issue with the google-auth library?


Discussion:
@davidfontenot What platform are you using? (I've seen this before on an old desktop running Ubuntu, but it was very hard to reproduce.)
@dhermes this is running in an alpine v3.4 Docker container running using Docker for Mac
I can definitely reproduce this on mac. It's taking way longer than it should. investigating.

Resolving patch:
diff --git a/google/auth/transport/_http_client.py b/google/auth/transport/_http_client.py
--- a/google/auth/transport/_http_client.py
+++ b/google/auth/transport/_http_client.py
@@ -94,7 +94,7 @@ def __call__(self, url, method='GET', body=None, headers=None,
                 'http.client transport only supports the http scheme, {}'
                 'was specified'.format(parts.scheme))
 
-        connection = http_client.HTTPConnection(parts.netloc)
+        connection = http_client.HTTPConnection(parts.netloc, timeout=timeout)
 
         try:
             _LOGGER.debug('Making request: %s %s', method, url)


Test patch:
diff --git a/tests/transport/compliance.py b/tests/transport/compliance.py
--- a/tests/transport/compliance.py
+++ b/tests/transport/compliance.py
@@ -12,6 +12,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+import time
+
 import flask
 import pytest
 from pytest_localserver.http import WSGIServer
@@ -47,6 +49,11 @@ def index():
         @app.route('/server_error')
         def server_error():
             return 'Error', http_client.INTERNAL_SERVER_ERROR
+
+        @app.route('/wait')
+        def wait():
+            time.sleep(3)
+            return 'Waited'
         # pylint: enable=unused-variable
 
         server = WSGIServer(application=app.wsgi_app)
@@ -62,7 +69,7 @@ def test_request_basic(self, server):
         assert response.headers['x-test-header'] == 'value'
         assert response.data == b'Basic Content'
 
-    def test_request_timeout(self, server):
+    def test_request_with_timeout_success(self, server):
         request = self.make_request()
         response = request(url=server.url + '/basic', method='GET', timeout=2)
 
@@ -70,6 +77,12 @@ def test_request_timeout(self, server):
         assert response.headers['x-test-header'] == 'value'
         assert response.data == b'Basic Content'
 
+    def test_request_with_timeout_failure(self, server):
+        request = self.make_request()
+
+        with pytest.raises(exceptions.TransportError):
+            request(url=server.url + '/wait', method='GET', timeout=1)
+
     def test_request_headers(self, server):
         request = self.make_request()
         response = request(