77
88from splitio .api import APIException
99from splitio .util .backoff import Backoff
10- from splitio .sync .split import _ON_DEMAND_FETCH_BACKOFF_BASE , _ON_DEMAND_FETCH_BACKOFF_MAX_RETRIES , _ON_DEMAND_FETCH_BACKOFF_MAX_WAIT
11-
10+ from splitio .sync .split import _ON_DEMAND_FETCH_BACKOFF_BASE , _ON_DEMAND_FETCH_BACKOFF_MAX_RETRIES , _ON_DEMAND_FETCH_BACKOFF_MAX_WAIT , LocalhostMode
1211
1312_LOGGER = logging .getLogger (__name__ )
1413_SYNC_ALL_NO_RETRIES = - 1
@@ -492,7 +491,7 @@ def stop_periodic_fetching(self):
492491class LocalhostSynchronizer (BaseSynchronizer ):
493492 """LocalhostSynchronizer."""
494493
495- def __init__ (self , split_synchronizers , split_tasks ):
494+ def __init__ (self , split_synchronizers , split_tasks , localhost_mode ):
496495 """
497496 Class constructor.
498497
@@ -503,6 +502,7 @@ def __init__(self, split_synchronizers, split_tasks):
503502 """
504503 self ._split_synchronizers = split_synchronizers
505504 self ._split_tasks = split_tasks
505+ self ._localhost_mode = localhost_mode
506506 self ._backoff = Backoff (
507507 _ON_DEMAND_FETCH_BACKOFF_BASE ,
508508 _ON_DEMAND_FETCH_BACKOFF_MAX_WAIT )
@@ -511,6 +511,10 @@ def sync_all(self, till=None):
511511 """
512512 Synchronize all splits.
513513 """
514+ # TODO: to be removed when legacy and yaml use BUR
515+ if self ._localhost_mode != LocalhostMode .JSON :
516+ return self .synchronize_splits ()
517+
514518 self ._backoff .reset ()
515519 remaining_attempts = _ON_DEMAND_FETCH_BACKOFF_MAX_RETRIES if till == None else till
516520 while remaining_attempts > 0 :
@@ -521,10 +525,6 @@ def sync_all(self, till=None):
521525 _LOGGER .error ('Failed syncing all' )
522526 _LOGGER .error (str (exc ))
523527
524- # TODO: to be removed when legacy use BUR
525- if till == 1 : # Legacy mode
526- raise Exception ("Failed to fetch Splits" )
527-
528528 how_long = self ._backoff .get ()
529529 time .sleep (how_long )
530530
0 commit comments