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

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

Issue 2578213005: Use underscores to separate words in filenames in webkitpy. (Closed)
Patch Set: Fix check for attribute in output_capture.py. 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 23 matching lines...) Expand all
34 34
35 35
36 class NetworkTimeout(Exception): 36 class NetworkTimeout(Exception):
37 37
38 def __str__(self): 38 def __str__(self):
39 return 'NetworkTimeout' 39 return 'NetworkTimeout'
40 40
41 41
42 class NetworkTransaction(object): 42 class NetworkTransaction(object):
43 43
44 # TODO(qyearsley): Rename convert_404_to_None
45 # pylint: disable=invalid-name
46
44 def __init__(self, initial_backoff_seconds=10, grown_factor=1.5, timeout_sec onds=(10 * 60), convert_404_to_None=False): 47 def __init__(self, initial_backoff_seconds=10, grown_factor=1.5, timeout_sec onds=(10 * 60), convert_404_to_None=False):
45 self._initial_backoff_seconds = initial_backoff_seconds 48 self._initial_backoff_seconds = initial_backoff_seconds
46 self._grown_factor = grown_factor 49 self._grown_factor = grown_factor
47 self._timeout_seconds = timeout_seconds 50 self._timeout_seconds = timeout_seconds
48 self._convert_404_to_None = convert_404_to_None 51 self._convert_404_to_None = convert_404_to_None
49 self._total_sleep = 0 52 self._total_sleep = 0
50 self._backoff_seconds = 0 53 self._backoff_seconds = 0
51 54
52 def run(self, request): 55 def run(self, request):
53 self._total_sleep = 0 56 self._total_sleep = 0
(...skipping 10 matching lines...) Expand all
64 self._sleep() 67 self._sleep()
65 68
66 def _check_for_timeout(self): 69 def _check_for_timeout(self):
67 if self._total_sleep + self._backoff_seconds > self._timeout_seconds: 70 if self._total_sleep + self._backoff_seconds > self._timeout_seconds:
68 raise NetworkTimeout() 71 raise NetworkTimeout()
69 72
70 def _sleep(self): 73 def _sleep(self):
71 time.sleep(self._backoff_seconds) 74 time.sleep(self._backoff_seconds)
72 self._total_sleep += self._backoff_seconds 75 self._total_sleep += self._backoff_seconds
73 self._backoff_seconds *= self._grown_factor 76 self._backoff_seconds *= self._grown_factor
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698