Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Unified Diff: infra_libs/httplib2_utils.py

Issue 1512643002: Added default timeout to InstrumentedHttp (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: infra_libs/httplib2_utils.py
diff --git a/infra_libs/httplib2_utils.py b/infra_libs/httplib2_utils.py
index 45c6e702644adf53855ac597cce3b3f0a8abf412..ee5f6aed8b1ee0f99f49ccc88aee147d2a882ac6 100644
--- a/infra_libs/httplib2_utils.py
+++ b/infra_libs/httplib2_utils.py
@@ -19,6 +19,9 @@ from infra_libs.ts_mon.common import http_metrics
DEFAULT_SCOPES = ['email']
+# default timeout for http requests, in seconds
+DEFAULT_TIMEOUT = 30
+
# This is part of the API.
if sys.platform.startswith('win'): # pragma: no cover
SERVICE_ACCOUNTS_CREDS_ROOT = 'C:\\creds\\service_accounts'
@@ -126,7 +129,7 @@ def get_authenticated_http(credentials_filename,
scope=None,
service_accounts_creds_root=None,
http_identifier=None,
- timeout=30):
+ timeout=DEFAULT_TIMEOUT):
"""Creates an httplib2.Http wrapped with a service account authenticator.
Args:
@@ -162,7 +165,8 @@ def get_authenticated_http(credentials_filename,
class InstrumentedHttp(httplib2.Http):
"""A httplib2.Http object that reports ts_mon metrics about its requests."""
- def __init__(self, name, time_fn=time.time, **kwargs):
+ def __init__(self, name, time_fn=time.time, timeout=DEFAULT_TIMEOUT,
+ **kwargs):
"""
Args:
name: An identifier for the HTTP requests made by this object.
@@ -170,7 +174,7 @@ class InstrumentedHttp(httplib2.Http):
purposes only.
"""
- super(InstrumentedHttp, self).__init__(**kwargs)
+ super(InstrumentedHttp, self).__init__(timeout=timeout, **kwargs)
self.fields = {'name': name, 'client': 'httplib2'}
self.time_fn = time_fn
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698