66import time
77
88from splitio .optional .loaders import asyncio
9- from splitio .api import APIException
9+ from splitio .api import APIException , APIUriException
1010from splitio .util .backoff import Backoff
1111from splitio .sync .split import _ON_DEMAND_FETCH_BACKOFF_BASE , _ON_DEMAND_FETCH_BACKOFF_MAX_RETRIES , _ON_DEMAND_FETCH_BACKOFF_MAX_WAIT , LocalhostMode
1212
@@ -252,7 +252,6 @@ def __init__(self, split_synchronizers, split_tasks):
252252 self ._periodic_data_recording_tasks .append (self ._split_tasks .unique_keys_task )
253253 if self ._split_tasks .clear_filter_task :
254254 self ._periodic_data_recording_tasks .append (self ._split_tasks .clear_filter_task )
255- self ._break_sync_all = False
256255
257256 @property
258257 def split_sync (self ):
@@ -354,7 +353,7 @@ def __init__(self, split_synchronizers, split_tasks):
354353 :param split_tasks: tasks for starting/stopping tasks
355354 :type split_tasks: splitio.sync.synchronizer.SplitTasks
356355 """
357- super () .__init__ (split_synchronizers , split_tasks )
356+ SynchronizerInMemoryBase .__init__ (self , split_synchronizers , split_tasks )
358357
359358 def _synchronize_segments (self ):
360359 _LOGGER .debug ('Starting segments synchronization' )
@@ -385,7 +384,6 @@ def synchronize_splits(self, till, sync_segments=True):
385384 :returns: whether the synchronization was successful or not.
386385 :rtype: bool
387386 """
388- self ._break_sync_all = False
389387 _LOGGER .debug ('Starting splits synchronization' )
390388 try :
391389 new_segments = []
@@ -401,9 +399,12 @@ def synchronize_splits(self, till, sync_segments=True):
401399 else :
402400 _LOGGER .debug ('Segment sync scheduled.' )
403401 return True
402+ except APIUriException as exc :
403+ _LOGGER .error ('Failed syncing feature flags due to long URI' )
404+ _LOGGER .debug ('Error: ' , exc_info = True )
405+ return False
406+
404407 except APIException as exc :
405- if exc ._status_code is not None and exc ._status_code == 414 :
406- self ._break_sync_all = True
407408 _LOGGER .error ('Failed syncing feature flags' )
408409 _LOGGER .debug ('Error: ' , exc_info = True )
409410 return False
@@ -428,12 +429,16 @@ def sync_all(self, max_retry_attempts=_SYNC_ALL_NO_RETRIES):
428429
429430 # All is good
430431 return
432+ except APIUriException as exc :
433+ _LOGGER .error ("URI too long exception, aborting retries." )
434+ _LOGGER .debug ('Error: ' , exc_info = True )
435+ break
431436 except Exception as exc : # pylint:disable=broad-except
432437 _LOGGER .error ("Exception caught when trying to sync all data: %s" , str (exc ))
433438 _LOGGER .debug ('Error: ' , exc_info = True )
434439 if max_retry_attempts != _SYNC_ALL_NO_RETRIES :
435440 retry_attempts += 1
436- if retry_attempts > max_retry_attempts or self . _break_sync_all :
441+ if retry_attempts > max_retry_attempts :
437442 break
438443 how_long = self ._backoff .get ()
439444 time .sleep (how_long )
@@ -508,7 +513,7 @@ def __init__(self, split_synchronizers, split_tasks):
508513 :param split_tasks: tasks for starting/stopping tasks
509514 :type split_tasks: splitio.sync.synchronizer.SplitTasks
510515 """
511- super () .__init__ (split_synchronizers , split_tasks )
516+ SynchronizerInMemoryBase .__init__ (self , split_synchronizers , split_tasks )
512517 self .stop_periodic_data_recording_task = None
513518
514519 async def _synchronize_segments (self ):
@@ -540,7 +545,6 @@ async def synchronize_splits(self, till, sync_segments=True):
540545 :returns: whether the synchronization was successful or not.
541546 :rtype: bool
542547 """
543- self ._break_sync_all = False
544548 _LOGGER .debug ('Starting feature flags synchronization' )
545549 try :
546550 new_segments = []
@@ -556,9 +560,12 @@ async def synchronize_splits(self, till, sync_segments=True):
556560 else :
557561 _LOGGER .debug ('Segment sync scheduled.' )
558562 return True
563+ except APIUriException as exc :
564+ _LOGGER .error ('Failed syncing feature flags due to long URI' )
565+ _LOGGER .debug ('Error: ' , exc_info = True )
566+ return False
567+
559568 except APIException as exc :
560- if exc ._status_code is not None and exc ._status_code == 414 :
561- self ._break_sync_all = True
562569 _LOGGER .error ('Failed syncing feature flags' )
563570 _LOGGER .debug ('Error: ' , exc_info = True )
564571 return False
@@ -583,12 +590,16 @@ async def sync_all(self, max_retry_attempts=_SYNC_ALL_NO_RETRIES):
583590
584591 # All is good
585592 return
593+ except APIUriException as exc :
594+ _LOGGER .error ("URI too long exception, aborting retries." )
595+ _LOGGER .debug ('Error: ' , exc_info = True )
596+ break
586597 except Exception as exc : # pylint:disable=broad-except
587598 _LOGGER .error ("Exception caught when trying to sync all data: %s" , str (exc ))
588599 _LOGGER .debug ('Error: ' , exc_info = True )
589600 if max_retry_attempts != _SYNC_ALL_NO_RETRIES :
590601 retry_attempts += 1
591- if retry_attempts > max_retry_attempts or self . _break_sync_all :
602+ if retry_attempts > max_retry_attempts :
592603 break
593604 how_long = self ._backoff .get ()
594605 time .sleep (how_long )
@@ -734,7 +745,7 @@ def __init__(self, split_synchronizers, split_tasks):
734745 :param split_tasks: tasks for starting/stopping tasks
735746 :type split_tasks: splitio.sync.synchronizer.SplitTasks
736747 """
737- super () .__init__ (split_synchronizers , split_tasks )
748+ RedisSynchronizerBase .__init__ (self , split_synchronizers , split_tasks )
738749
739750 def shutdown (self , blocking ):
740751 """
@@ -779,7 +790,7 @@ def __init__(self, split_synchronizers, split_tasks):
779790 :param split_tasks: tasks for starting/stopping tasks
780791 :type split_tasks: splitio.sync.synchronizer.SplitTasks
781792 """
782- super () .__init__ (split_synchronizers , split_tasks )
793+ RedisSynchronizerBase .__init__ (self , split_synchronizers , split_tasks )
783794 self .stop_periodic_data_recording_task = None
784795
785796 async def shutdown (self , blocking ):
@@ -895,7 +906,7 @@ def __init__(self, split_synchronizers, split_tasks, localhost_mode):
895906 :param split_tasks: tasks for starting/stopping tasks
896907 :type split_tasks: splitio.sync.synchronizer.SplitTasks
897908 """
898- super () .__init__ (split_synchronizers , split_tasks , localhost_mode )
909+ LocalhostSynchronizerBase .__init__ (self , split_synchronizers , split_tasks , localhost_mode )
899910
900911 def sync_all (self , till = None ):
901912 """
@@ -969,7 +980,7 @@ def __init__(self, split_synchronizers, split_tasks, localhost_mode):
969980 :param split_tasks: tasks for starting/stopping tasks
970981 :type split_tasks: splitio.sync.synchronizer.SplitTasks
971982 """
972- super () .__init__ (split_synchronizers , split_tasks , localhost_mode )
983+ LocalhostSynchronizerBase .__init__ (self , split_synchronizers , split_tasks , localhost_mode )
973984
974985 async def sync_all (self , till = None ):
975986 """
0 commit comments