1010
1111
1212_LOGGER = logging .getLogger (__name__ )
13-
13+ _SYNC_ALL_NO_RETRIES = - 1
1414
1515class SplitSynchronizers (object ):
1616 """SplitSynchronizers."""
@@ -292,7 +292,7 @@ def synchronize_splits(self, till, sync_segments=True):
292292 _LOGGER .debug ('Error: ' , exc_info = True )
293293 return False
294294
295- def sync_all (self , max_retry_attempts = - 1 ):
295+ def sync_all (self , max_retry_attempts = _SYNC_ALL_NO_RETRIES ):
296296 """
297297 Synchronize all splits.
298298
@@ -303,10 +303,7 @@ def sync_all(self, max_retry_attempts=-1):
303303 while True :
304304 try :
305305 if not self .synchronize_splits (None , False ):
306- retry_attempts = self ._retry_block (max_retry_attempts , retry_attempts )
307- if max_retry_attempts != - 1 and retry_attempts == - 1 :
308- break
309- continue
306+ raise Exception ("split sync failed" )
310307
311308 # Only retrying splits, since segments may trigger too many calls.
312309 if not self ._synchronize_segments ():
@@ -317,20 +314,16 @@ def sync_all(self, max_retry_attempts=-1):
317314 except Exception as exc : # pylint:disable=broad-except
318315 _LOGGER .error ("Exception caught when trying to sync all data: %s" , str (exc ))
319316 _LOGGER .debug ('Error: ' , exc_info = True )
320- retry_attempts = self ._retry_block (max_retry_attempts , retry_attempts )
321- if max_retry_attempts != - 1 and retry_attempts == - 1 :
322- break
323- continue
317+ if max_retry_attempts != _SYNC_ALL_NO_RETRIES :
318+ retry_attempts += 1
319+ if retry_attempts > max_retry_attempts :
320+ break
321+ how_long = self ._backoff .get ()
322+ time .sleep (how_long )
324323
325324 _LOGGER .error ("Could not correctly synchronize splits and segments after %d attempts." , retry_attempts )
326325
327326 def _retry_block (self , max_retry_attempts , retry_attempts ):
328- if max_retry_attempts != - 1 :
329- retry_attempts += 1
330- if retry_attempts > max_retry_attempts :
331- return - 1
332- how_long = self ._backoff .get ()
333- time .sleep (how_long )
334327 return retry_attempts
335328
336329 def shutdown (self , blocking ):
0 commit comments