Skip to content

Commit a07dac5

Browse files
committed
feat: Add async FDv2 data sources
1 parent fd041a5 commit a07dac5

13 files changed

Lines changed: 2110 additions & 202 deletions

File tree

ldclient/impl/aio/concurrency.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,6 @@ async def _run(self):
242242
result = self.__action()
243243
if inspect.isawaitable(result):
244244
await result
245-
except asyncio.CancelledError:
246-
raise
247245
except Exception as e:
248246
log.exception("Unexpected exception on worker task: %s" % e)
249247
delay = next_time - time.time()

ldclient/impl/datasource/async_status.py

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
from ldclient.impl.dependency_tracker import DependencyTracker, KindAndKey
55
from ldclient.impl.listeners import Listeners
6-
from ldclient.impl.rwlock import ReadWriteLock
76
from ldclient.interfaces import (
87
AsyncDataSourceUpdateSink,
98
AsyncFeatureStore,
@@ -23,13 +22,11 @@ def __init__(self, store: AsyncFeatureStore, status_listeners: Listeners, flag_c
2322
self.__flag_change_listeners = flag_change_listeners
2423
self.__tracker = DependencyTracker()
2524

26-
self.__lock = ReadWriteLock()
2725
self.__status = DataSourceStatus(DataSourceState.INITIALIZING, time.time(), None)
2826

2927
@property
3028
def status(self) -> DataSourceStatus:
31-
with self.__lock.read():
32-
return self.__status
29+
return self.__status
3330

3431
async def init(self, all_data: Mapping[VersionedDataKind, Mapping[str, dict]]) -> None:
3532
old_data: Optional[Dict[VersionedDataKind, Mapping[str, dict]]] = None
@@ -73,22 +70,21 @@ async def delete(self, kind: VersionedDataKind, key: str, version: int) -> None:
7370
def update_status(self, new_state: DataSourceState, new_error: Optional[DataSourceErrorInfo]) -> None:
7471
status_to_broadcast = None
7572

76-
with self.__lock.write():
77-
old_status = self.__status
73+
old_status = self.__status
7874

79-
if new_state == DataSourceState.INTERRUPTED and old_status.state == DataSourceState.INITIALIZING:
80-
new_state = DataSourceState.INITIALIZING
75+
if new_state == DataSourceState.INTERRUPTED and old_status.state == DataSourceState.INITIALIZING:
76+
new_state = DataSourceState.INITIALIZING
8177

82-
if new_state == old_status.state and new_error is None:
83-
return
78+
if new_state == old_status.state and new_error is None:
79+
return
8480

85-
self.__status = DataSourceStatus(
86-
new_state,
87-
self.__status.since if new_state == self.__status.state else time.time(),
88-
self.__status.error if new_error is None else new_error,
89-
)
81+
self.__status = DataSourceStatus(
82+
new_state,
83+
self.__status.since if new_state == self.__status.state else time.time(),
84+
self.__status.error if new_error is None else new_error,
85+
)
9086

91-
status_to_broadcast = self.__status
87+
status_to_broadcast = self.__status
9288

9389
if status_to_broadcast is not None:
9490
self.__status_listeners.notify(status_to_broadcast)

0 commit comments

Comments
 (0)