Skip to content

Commit 40973e8

Browse files
committed
polishing
1 parent da9ff77 commit 40973e8

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

splitio/push/splitworker.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ def _get_feature_flag_definition(self, event):
5454
cm = CompressionMode(event.compression) # will throw if the number is not defined in compression mode
5555
return self._compression_handlers[cm](event)
5656

57+
def _check_instant_ff_update(self, event):
58+
if event.update_type == UpdateType.SPLIT_UPDATE:
59+
if event.compression is not None and event.previous_change_number == self._feature_flag_storage.get_change_number():
60+
return True
61+
return False
62+
63+
5764
def _run(self):
5865
"""Run worker handler."""
5966
while self.is_running():
@@ -64,17 +71,16 @@ def _run(self):
6471
continue
6572
_LOGGER.debug('Processing feature flag update %d', event.change_number)
6673
try:
67-
if event.update_type == UpdateType.SPLIT_UPDATE:
68-
if event.compression is not None and event.previous_change_number == self._feature_flag_storage.get_change_number():
69-
try:
70-
self._feature_flag_storage.put(from_raw(json.loads(self._get_feature_flag_definition(event))))
71-
self._feature_flag_storage.set_change_number(event.change_number)
72-
continue
73-
except Exception as e:
74-
_LOGGER.error('Exception raised in updating feature flag')
75-
_LOGGER.debug(str(e))
76-
_LOGGER.debug('Exception information: ', exc_info=True)
77-
pass
74+
if self._check_instant_ff_update(event):
75+
try:
76+
self._feature_flag_storage.put(from_raw(json.loads(self._get_feature_flag_definition(event))))
77+
self._feature_flag_storage.set_change_number(event.change_number)
78+
continue
79+
except Exception as e:
80+
_LOGGER.error('Exception raised in updating feature flag')
81+
_LOGGER.debug(str(e))
82+
_LOGGER.debug('Exception information: ', exc_info=True)
83+
pass
7884
self._handler(event.change_number)
7985
except Exception as e: # pylint: disable=broad-except
8086
_LOGGER.error('Exception raised in feature flag synchronization')

0 commit comments

Comments
 (0)