Skip to content

Commit e151f86

Browse files
committed
chore: Minor cleanup
1 parent 468afdf commit e151f86

File tree

5 files changed

+12
-17
lines changed

5 files changed

+12
-17
lines changed

ldclient/impl/datasource/feature_requester.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from ldclient.interfaces import FeatureRequester
1414
from ldclient.versioned_data_kind import FEATURES, SEGMENTS
1515

16-
LATEST_ALL_URI = '/sdk/latest-all'
16+
FDV1_POLLING_ENDPOINT = '/sdk/latest-all'
1717

1818

1919
CacheEntry = namedtuple('CacheEntry', ['data', 'etag'])
@@ -24,7 +24,7 @@ def __init__(self, config):
2424
self._cache = dict()
2525
self._http = _http_factory(config).create_pool_manager(1, config.base_uri)
2626
self._config = config
27-
self._poll_uri = config.base_uri + LATEST_ALL_URI
27+
self._poll_uri = config.base_uri + FDV1_POLLING_ENDPOINT
2828
if config.payload_filter_key is not None:
2929
self._poll_uri += '?%s' % parse.urlencode({'filter': config.payload_filter_key})
3030

ldclient/impl/datasourcev2/polling.py

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@
1414
import urllib3
1515

1616
from ldclient.config import Config
17-
from ldclient.impl.datasource.feature_requester import LATEST_ALL_URI
17+
from ldclient.impl.datasource.feature_requester import FDV1_POLLING_ENDPOINT
1818
from ldclient.impl.datasystem.protocolv2 import (
1919
DeleteObject,
2020
EventName,
2121
PutObject
2222
)
2323
from ldclient.impl.http import _http_factory
24-
from ldclient.impl.repeating_task import RepeatingTask
2524
from ldclient.impl.util import (
2625
_LD_ENVID_HEADER,
2726
_LD_FD_FALLBACK_HEADER,
@@ -52,7 +51,7 @@
5251
Update
5352
)
5453

55-
POLLING_ENDPOINT = "/sdk/poll"
54+
FDV2_POLLING_ENDPOINT = "/sdk/poll"
5655

5756

5857
PollingResult = _Result[Tuple[ChangeSet, Mapping], str]
@@ -93,11 +92,8 @@ def __init__(
9392
):
9493
self._requester = requester
9594
self._poll_interval = poll_interval
96-
self._event = Event()
95+
self._interrupt_event = Event()
9796
self._stop = Event()
98-
self._task = RepeatingTask(
99-
"ldclient.datasource.polling", poll_interval, 0, self._poll
100-
)
10197

10298
@property
10399
def name(self) -> str:
@@ -117,6 +113,7 @@ def sync(self, ss: SelectorStore) -> Generator[Update, None, None]:
117113
occurs.
118114
"""
119115
log.info("Starting PollingDataSourceV2 synchronizer")
116+
self._interrupt_event.clear()
120117
self._stop.clear()
121118
while self._stop.is_set() is False:
122119
result = self._requester.fetch(ss.selector())
@@ -184,14 +181,13 @@ def sync(self, ss: SelectorStore) -> Generator[Update, None, None]:
184181
revert_to_fdv1=headers.get(_LD_FD_FALLBACK_HEADER) == 'true'
185182
)
186183

187-
if self._event.wait(self._poll_interval):
184+
if self._interrupt_event.wait(self._poll_interval):
188185
break
189186

190187
def stop(self):
191188
"""Stops the synchronizer."""
192189
log.info("Stopping PollingDataSourceV2 synchronizer")
193-
self._event.set()
194-
self._task.stop()
190+
self._interrupt_event.set()
195191
self._stop.set()
196192

197193
def _poll(self, ss: SelectorStore) -> BasisResult:
@@ -247,7 +243,7 @@ def __init__(self, config: Config):
247243
self._etag = None
248244
self._http = _http_factory(config).create_pool_manager(1, config.base_uri)
249245
self._config = config
250-
self._poll_uri = config.base_uri + POLLING_ENDPOINT
246+
self._poll_uri = config.base_uri + FDV2_POLLING_ENDPOINT
251247

252248
def fetch(self, selector: Optional[Selector]) -> PollingResult:
253249
"""
@@ -413,7 +409,7 @@ def __init__(self, config: Config):
413409
self._etag = None
414410
self._http = _http_factory(config).create_pool_manager(1, config.base_uri)
415411
self._config = config
416-
self._poll_uri = config.base_uri + LATEST_ALL_URI
412+
self._poll_uri = config.base_uri + FDV1_POLLING_ENDPOINT
417413

418414
def fetch(self, selector: Optional[Selector]) -> PollingResult:
419415
"""

ldclient/impl/datasystem/store.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ def apply_delta(self, collections: Collections) -> bool:
111111
with self._lock.write():
112112
for kind, kind_data in all_decoded.items():
113113
items_of_kind = self._items[kind]
114-
kind_data = all_decoded[kind]
115114
for key, item in kind_data.items():
116115
items_of_kind[key] = item
117116
log.debug(

ldclient/integrations/test_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def __init__(self, key: str):
153153
# consider it part of the public API, but it is still called from TestData.
154154
def _copy(self) -> 'FlagBuilder':
155155
"""Creates a deep copy of the flag builder. Subsequent updates to the
156-
original ``FlagBuilder`` object will not update the copy and vise versa.
156+
original ``FlagBuilder`` object will not update the copy and vice versa.
157157
158158
:return: a copy of the flag builder object
159159
"""

ldclient/integrations/test_datav2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def __init__(self, key: str):
182182
def _copy(self) -> FlagBuilderV2:
183183
"""
184184
Creates a deep copy of the flag builder. Subsequent updates to the
185-
original ``FlagBuilderV2`` object will not update the copy and vise versa.
185+
original ``FlagBuilderV2`` object will not update the copy and vice versa.
186186
187187
:return: a copy of the flag builder object
188188
"""

0 commit comments

Comments
 (0)