1414import urllib3
1515
1616from 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
1818from ldclient .impl .datasystem .protocolv2 import (
1919 DeleteObject ,
2020 EventName ,
2121 PutObject
2222)
2323from ldclient .impl .http import _http_factory
24- from ldclient .impl .repeating_task import RepeatingTask
2524from ldclient .impl .util import (
2625 _LD_ENVID_HEADER ,
2726 _LD_FD_FALLBACK_HEADER ,
5251 Update
5352)
5453
55- POLLING_ENDPOINT = "/sdk/poll"
54+ FDV2_POLLING_ENDPOINT = "/sdk/poll"
5655
5756
5857PollingResult = _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 """
0 commit comments