File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -184,13 +184,11 @@ def get_service_shards(service):
184184 returns (int): the number of shards defined in the configuration.
185185
186186 """
187- i = 0
188- while True :
187+ for i in itertools .count ():
189188 try :
190189 get_service_address (ServiceCoord (service , i ))
191190 except KeyError :
192191 return i
193- i += 1
194192
195193
196194def default_argument_parser (description , cls , ask_contest = None ):
Original file line number Diff line number Diff line change @@ -204,9 +204,7 @@ def kill(self):
204204 def _check_with_backoff (self ):
205205 """Check and wait that the service is healthy."""
206206 self .healthy = False
207- attempts = 0
208- while attempts < _MAX_ATTEMPTS :
209- attempts += 1
207+ for attempts in range (_MAX_ATTEMPTS ):
210208 self ._check ()
211209 if not self .healthy :
212210 time .sleep (0.2 * (1.2 ** attempts ))
@@ -321,9 +319,7 @@ def count_unhealthy(self):
321319 return len ([p for p in itervalues (self ._programs ) if not p .healthy ])
322320
323321 def wait (self ):
324- attempts = 0
325- while attempts <= _MAX_ATTEMPTS :
326- attempts += 1
322+ for attempts in range (_MAX_ATTEMPTS ):
327323 unhealthy = self .count_unhealthy ()
328324 if unhealthy == 0 :
329325 logger .info ("All healthy! Continuing." )
You can’t perform that action at this time.
0 commit comments