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

Side by Side Diff: third_party/upload.py

Issue 6345001: Work around App Engine flakiness by retrying upon URLError... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/
Patch Set: '' Created 9 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright 2007 Google Inc. 3 # Copyright 2007 Google Inc.
4 # 4 #
5 # Licensed under the Apache License, Version 2.0 (the "License"); 5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License. 6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at 7 # You may obtain a copy of the License at
8 # 8 #
9 # http://www.apache.org/licenses/LICENSE-2.0 9 # http://www.apache.org/licenses/LICENSE-2.0
10 # 10 #
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 req = self._CreateRequest(url=url, data=payload) 395 req = self._CreateRequest(url=url, data=payload)
396 req.add_header("Content-Type", content_type) 396 req.add_header("Content-Type", content_type)
397 if extra_headers: 397 if extra_headers:
398 for header, value in extra_headers.items(): 398 for header, value in extra_headers.items():
399 req.add_header(header, value) 399 req.add_header(header, value)
400 try: 400 try:
401 f = self.opener.open(req) 401 f = self.opener.open(req)
402 response = f.read() 402 response = f.read()
403 f.close() 403 f.close()
404 return response 404 return response
405 except urllib2.URLError, e:
406 reason = e.reason
407 if isinstance(reason, str) and reason.find("110") != -1:
408 # Connection timeout error.
409 if tries <= 3:
410 # Try again.
411 continue
412 raise
405 except urllib2.HTTPError, e: 413 except urllib2.HTTPError, e:
406 if tries > 3: 414 if tries > 3:
407 raise 415 raise
408 elif e.code == 401 or e.code == 302: 416 elif e.code == 401 or e.code == 302:
409 url_loc = urlparse.urlparse(url) 417 url_loc = urlparse.urlparse(url)
410 self._Authenticate('%s://%s' % (url_loc[0], url_loc[1])) 418 self._Authenticate('%s://%s' % (url_loc[0], url_loc[1]))
411 ## elif e.code >= 500 and e.code < 600: 419 ## elif e.code >= 500 and e.code < 600:
412 ## # Server Error - try again. 420 ## # Server Error - try again.
413 ## continue 421 ## continue
414 elif e.code == 301: 422 elif e.code == 301:
(...skipping 1362 matching lines...) Expand 10 before | Expand all | Expand 10 after
1777 try: 1785 try:
1778 RealMain(sys.argv) 1786 RealMain(sys.argv)
1779 except KeyboardInterrupt: 1787 except KeyboardInterrupt:
1780 print 1788 print
1781 StatusUpdate("Interrupted.") 1789 StatusUpdate("Interrupted.")
1782 sys.exit(1) 1790 sys.exit(1)
1783 1791
1784 1792
1785 if __name__ == "__main__": 1793 if __name__ == "__main__":
1786 main() 1794 main()
OLDNEW
« 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