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

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/common/net/network_transaction.py

Issue 2580293002: Style change: Rename error variables "e" -> "error" (Closed)
Patch Set: Rebase and fix formatter unittest. Created 4 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 unified diff | Download patch
OLDNEW
1 # Copyright (C) 2010 Google Inc. All rights reserved. 1 # Copyright (C) 2010 Google Inc. All rights reserved.
2 # 2 #
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer 10 # copyright notice, this list of conditions and the following disclaimer
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 self._convert_404_to_None = convert_404_to_None 51 self._convert_404_to_None = convert_404_to_None
52 self._total_sleep = 0 52 self._total_sleep = 0
53 self._backoff_seconds = 0 53 self._backoff_seconds = 0
54 54
55 def run(self, request): 55 def run(self, request):
56 self._total_sleep = 0 56 self._total_sleep = 0
57 self._backoff_seconds = self._initial_backoff_seconds 57 self._backoff_seconds = self._initial_backoff_seconds
58 while True: 58 while True:
59 try: 59 try:
60 return request() 60 return request()
61 except urllib2.HTTPError as e: 61 except urllib2.HTTPError as error:
62 if self._convert_404_to_None and e.code == 404: 62 if self._convert_404_to_None and error.code == 404:
63 return None 63 return None
64 self._check_for_timeout() 64 self._check_for_timeout()
65 _log.warning("Received HTTP status %s loading \"%s\". Retrying in %s seconds...", 65 _log.warning("Received HTTP status %s loading \"%s\". Retrying in %s seconds...",
66 e.code, e.filename, self._backoff_seconds) 66 error.code, error.filename, self._backoff_seconds)
67 self._sleep() 67 self._sleep()
68 68
69 def _check_for_timeout(self): 69 def _check_for_timeout(self):
70 if self._total_sleep + self._backoff_seconds > self._timeout_seconds: 70 if self._total_sleep + self._backoff_seconds > self._timeout_seconds:
71 raise NetworkTimeout() 71 raise NetworkTimeout()
72 72
73 def _sleep(self): 73 def _sleep(self):
74 time.sleep(self._backoff_seconds) 74 time.sleep(self._backoff_seconds)
75 self._total_sleep += self._backoff_seconds 75 self._total_sleep += self._backoff_seconds
76 self._backoff_seconds *= self._grown_factor 76 self._backoff_seconds *= self._grown_factor
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698