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

Side by Side Diff: infra_libs/httplib2_utils.py

Issue 2127373005: Fix RetriableHttp (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Fix RetriableHttp Created 4 years, 5 months 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 unified diff | Download patch
« no previous file with comments | « no previous file | infra_libs/test/httplib2_utils_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import collections 5 import collections
6 import copy 6 import copy
7 import json 7 import json
8 import logging 8 import logging
9 import os 9 import os
10 import re 10 import re
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 'will retry') 199 'will retry')
200 if i == self._max_tries: 200 if i == self._max_tries:
201 raise 201 raise
202 202
203 return response, content 203 return response, content
204 204
205 def __getattr__(self, name): 205 def __getattr__(self, name):
206 return getattr(self._http, name) 206 return getattr(self._http, name)
207 207
208 def __setattr__(self, name, value): 208 def __setattr__(self, name, value):
209 if name in ('_http', '_max_tries', '_retrying_statuses_fn'): 209 if name in ('request', '_http', '_max_tries', '_retrying_statuses_fn'):
210 self.__dict__[name] = value 210 self.__dict__[name] = value
211 else: 211 else:
212 setattr(self._http, name, value) 212 setattr(self._http, name, value)
213 213
214 class InstrumentedHttp(httplib2.Http): 214 class InstrumentedHttp(httplib2.Http):
215 """A httplib2.Http object that reports ts_mon metrics about its requests.""" 215 """A httplib2.Http object that reports ts_mon metrics about its requests."""
216 216
217 def __init__(self, name, time_fn=time.time, timeout=DEFAULT_TIMEOUT, 217 def __init__(self, name, time_fn=time.time, timeout=DEFAULT_TIMEOUT,
218 **kwargs): 218 **kwargs):
219 """ 219 """
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 self.requests_made.append(self.HttpCall(uri, method, body, headers)) 306 self.requests_made.append(self.HttpCall(uri, method, body, headers))
307 headers = None 307 headers = None
308 body = None 308 body = None
309 for candidate in self._uris: 309 for candidate in self._uris:
310 if candidate[0].match(uri): 310 if candidate[0].match(uri):
311 _, headers, body = candidate 311 _, headers, body = candidate
312 break 312 break
313 if not headers: 313 if not headers:
314 raise AssertionError("Unexpected request to %s" % uri) 314 raise AssertionError("Unexpected request to %s" % uri)
315 return httplib2.Response(headers), body 315 return httplib2.Response(headers), body
OLDNEW
« no previous file with comments | « no previous file | infra_libs/test/httplib2_utils_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698