Skip to content

Commit 99bd61d

Browse files
committed
Added final_segment_list in split sync iteration
1 parent 18b5166 commit 99bd61d

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

splitio/sync/split.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,16 @@ def _attempt_split_sync(self, fetch_options, till=None):
9696
:rtype: bool, int, int
9797
"""
9898
self._backoff.reset()
99+
final_segment_list = set()
99100
remaining_attempts = _ON_DEMAND_FETCH_BACKOFF_MAX_RETRIES
100101
while True:
101102
remaining_attempts -= 1
102103
change_number, segment_list = self._fetch_until(fetch_options, till)
104+
final_segment_list.update(segment_list)
103105
if till is None or till <= change_number:
104-
return True, remaining_attempts, change_number, segment_list
106+
return True, remaining_attempts, change_number, final_segment_list
105107
elif remaining_attempts <= 0:
106-
return False, remaining_attempts, change_number, segment_list
108+
return False, remaining_attempts, change_number, final_segment_list
107109
how_long = self._backoff.get()
108110
time.sleep(how_long)
109111

@@ -114,20 +116,23 @@ def synchronize_splits(self, till=None):
114116
:param till: Passed till from Streaming.
115117
:type till: int
116118
"""
119+
final_segment_list = set()
117120
fetch_options = FetchOptions(True) # Set Cache-Control to no-cache
118121
successful_sync, remaining_attempts, change_number, segment_list = self._attempt_split_sync(fetch_options,
119122
till)
123+
final_segment_list.update(segment_list)
120124
attempts = _ON_DEMAND_FETCH_BACKOFF_MAX_RETRIES - remaining_attempts
121125
if successful_sync: # succedeed sync
122126
_LOGGER.debug('Refresh completed in %d attempts.', attempts)
123-
return segment_list
127+
return final_segment_list
124128
with_cdn_bypass = FetchOptions(True, change_number) # Set flag for bypassing CDN
125129
without_cdn_successful_sync, remaining_attempts, change_number, segment_list = self._attempt_split_sync(with_cdn_bypass, till)
130+
final_segment_list.update(segment_list)
126131
without_cdn_attempts = _ON_DEMAND_FETCH_BACKOFF_MAX_RETRIES - remaining_attempts
127132
if without_cdn_successful_sync:
128133
_LOGGER.debug('Refresh completed bypassing the CDN in %d attempts.',
129134
without_cdn_attempts)
130-
return segment_list
135+
return final_segment_list
131136
else:
132137
_LOGGER.debug('No changes fetched after %d attempts with CDN bypassed.',
133138
without_cdn_attempts)

0 commit comments

Comments
 (0)