Skip to content

Commit ec04a4e

Browse files
committed
[sdk-1710] update naming
1 parent 320e723 commit ec04a4e

File tree

12 files changed

+59
-59
lines changed

12 files changed

+59
-59
lines changed

ldclient/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def set_config(config: Config):
3737
global __config
3838
global __client
3939
global __lock
40-
with __lock.write_lock():
40+
with __lock.write():
4141
try:
4242
if __client:
4343
log.info("Reinitializing LaunchDarkly Client " + VERSION + " with new config")
@@ -62,13 +62,13 @@ def get() -> LDClient:
6262
global __config
6363
global __client
6464
global __lock
65-
with __lock.read_lock():
65+
with __lock.read():
6666
if __client:
6767
return __client
6868
if __config is None:
6969
raise Exception("set_config was not called")
7070

71-
with __lock.write_lock():
71+
with __lock.write():
7272
if not __client:
7373
log.info("Initializing LaunchDarkly Client " + VERSION)
7474
__client = LDClient(config=__config, start_wait=start_wait)
@@ -80,7 +80,7 @@ def _reset_client():
8080
global __client
8181
global __lock
8282
c = None
83-
with __lock.write_lock():
83+
with __lock.write():
8484
c = __client
8585
__client = None
8686
if c:

ldclient/client.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def __wrapper(self, fn: Callable):
111111
raise
112112

113113
def __update_availability(self, available: bool):
114-
with self.__lock.write_lock():
114+
with self.__lock.write():
115115
if available == self.__last_available:
116116
return
117117
self.__last_available = available
@@ -124,7 +124,7 @@ def __update_availability(self, available: bool):
124124
self.__store_update_sink.update_status(status)
125125

126126
if available:
127-
with self.__lock.write_lock():
127+
with self.__lock.write():
128128
if self.__poller is not None:
129129
self.__poller.stop()
130130
self.__poller = None
@@ -134,7 +134,7 @@ def __update_availability(self, available: bool):
134134
log.warn("Detected persistent store unavailability; updates will be cached until it recovers")
135135
task = RepeatingTask("ldclient.check-availability", 0.5, 0, self.__check_availability)
136136

137-
with self.__lock.write_lock():
137+
with self.__lock.write():
138138
self.__poller = task
139139
self.__poller.start()
140140

@@ -710,7 +710,7 @@ def add_hook(self, hook: Hook):
710710
if not isinstance(hook, Hook):
711711
return
712712

713-
with self.__hooks_lock.write_lock():
713+
with self.__hooks_lock.write():
714714
self.__hooks.append(hook)
715715

716716
def __evaluate_with_hooks(self, key: str, context: Context, default_value: Any, method: str, block: Callable[[], _EvaluationWithHookResult]) -> _EvaluationWithHookResult:
@@ -725,7 +725,7 @@ def __evaluate_with_hooks(self, key: str, context: Context, default_value: Any,
725725
# :return:
726726
"""
727727
hooks = [] # type: List[Hook]
728-
with self.__hooks_lock.read_lock():
728+
with self.__hooks_lock.read():
729729
if len(self.__hooks) == 0:
730730
return block()
731731

ldclient/feature_store.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def is_available(self) -> bool:
7777

7878
def get(self, kind: VersionedDataKind, key: str, callback: Callable[[Any], Any] = lambda x: x) -> Any:
7979
""" """
80-
with self._lock.read_lock():
80+
with self._lock.read():
8181
itemsOfKind = self._items[kind]
8282
item = itemsOfKind.get(key)
8383
if item is None:
@@ -90,7 +90,7 @@ def get(self, kind: VersionedDataKind, key: str, callback: Callable[[Any], Any]
9090

9191
def all(self, kind, callback):
9292
""" """
93-
with self._lock.read_lock():
93+
with self._lock.read():
9494
itemsOfKind = self._items[kind]
9595
return callback(dict((k, i) for k, i in itemsOfKind.items() if ('deleted' not in i) or not i['deleted']))
9696

@@ -102,7 +102,7 @@ def init(self, all_data):
102102
for key, item in items.items():
103103
items_decoded[key] = kind.decode(item)
104104
all_decoded[kind] = items_decoded
105-
with self._lock.write_lock():
105+
with self._lock.write():
106106
self._items.clear()
107107
self._items.update(all_decoded)
108108
self._initialized = True
@@ -112,7 +112,7 @@ def init(self, all_data):
112112
# noinspection PyShadowingNames
113113
def delete(self, kind, key: str, version: int):
114114
""" """
115-
with self._lock.write_lock():
115+
with self._lock.write():
116116
itemsOfKind = self._items[kind]
117117
i = itemsOfKind.get(key)
118118
if i is None or i['version'] < version:
@@ -123,7 +123,7 @@ def upsert(self, kind, item):
123123
""" """
124124
decoded_item = kind.decode(item)
125125
key = item['key']
126-
with self._lock.write_lock():
126+
with self._lock.write():
127127
itemsOfKind = self._items[kind]
128128
i = itemsOfKind.get(key)
129129
if i is None or i['version'] < item['version']:
@@ -133,7 +133,7 @@ def upsert(self, kind, item):
133133
@property
134134
def initialized(self) -> bool:
135135
""" """
136-
with self._lock.read_lock():
136+
with self._lock.read():
137137
return self._initialized
138138

139139
def describe_configuration(self, config):

ldclient/impl/datasource/status.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def __init__(self, store: FeatureStore, status_listeners: Listeners, flag_change
2929

3030
@property
3131
def status(self) -> DataSourceStatus:
32-
with self.__lock.read_lock():
32+
with self.__lock.read():
3333
return self.__status
3434

3535
def init(self, all_data: Mapping[VersionedDataKind, Mapping[str, dict]]):
@@ -67,7 +67,7 @@ def delete(self, kind: VersionedDataKind, key: str, version: int):
6767
def update_status(self, new_state: DataSourceState, new_error: Optional[DataSourceErrorInfo]):
6868
status_to_broadcast = None
6969

70-
with self.__lock.write_lock():
70+
with self.__lock.write():
7171
old_status = self.__status
7272

7373
if new_state == DataSourceState.INTERRUPTED and old_status.state == DataSourceState.INITIALIZING:

ldclient/impl/datastore/status.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ def listeners(self) -> Listeners:
2727
return self.__listeners
2828

2929
def status(self) -> DataStoreStatus:
30-
with self.__lock.read_lock():
30+
with self.__lock.read():
3131
return copy(self.__status)
3232

3333
def update_status(self, status: DataStoreStatus):
34-
with self.__lock.write_lock():
34+
with self.__lock.write():
3535
old_value, self.__status = self.__status, status
3636

3737
if old_value != status:

ldclient/impl/datasystem/fdv2.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ def __init__(self, listeners: Listeners):
4242

4343
@property
4444
def status(self) -> DataSourceStatus:
45-
with self.__lock.read_lock():
45+
with self.__lock.read():
4646
return self.__status
4747

4848
def update_status(self, new_state: DataSourceState, new_error: Optional[DataSourceErrorInfo]):
4949
status_to_broadcast = None
5050

51-
with self.__lock.write_lock():
51+
with self.__lock.write():
5252
old_status = self.__status
5353

5454
if new_state == DataSourceState.INTERRUPTED and old_status.state == DataSourceState.INITIALIZING:
@@ -88,7 +88,7 @@ def update_status(self, status: DataStoreStatus):
8888
"""
8989
modified = False
9090

91-
with self.__lock.write_lock():
91+
with self.__lock.write():
9292
if self.__status != status:
9393
self.__status = status
9494
modified = True
@@ -98,7 +98,7 @@ def update_status(self, status: DataStoreStatus):
9898

9999
@property
100100
def status(self) -> DataStoreStatus:
101-
with self.__lock.read_lock():
101+
with self.__lock.read():
102102
return copy(self.__status)
103103

104104
def is_monitoring_enabled(self) -> bool:
@@ -163,7 +163,7 @@ def __update_availability(self, available: bool):
163163
poller_to_stop = None
164164
task_to_start = None
165165

166-
with self.__lock.write_lock():
166+
with self.__lock.write():
167167
if available == self.__last_available:
168168
return
169169

@@ -322,7 +322,7 @@ def stop(self):
322322
"""Stop the FDv2 data system and all associated threads."""
323323
self._stop_event.set()
324324

325-
with self._lock.write_lock():
325+
with self._lock.write():
326326
if self._active_synchronizer is not None:
327327
try:
328328
self._active_synchronizer.stop()
@@ -411,7 +411,7 @@ def synchronizer_loop(self: 'FDv2'):
411411
while not self._stop_event.is_set() and self._primary_synchronizer_builder is not None:
412412
# Try primary synchronizer
413413
try:
414-
with self._lock.write_lock():
414+
with self._lock.write():
415415
primary_sync = self._primary_synchronizer_builder(self._config)
416416
if isinstance(primary_sync, DiagnosticSource) and self._diagnostic_accumulator is not None:
417417
primary_sync.set_diagnostic_accumulator(self._diagnostic_accumulator)
@@ -446,7 +446,7 @@ def synchronizer_loop(self: 'FDv2'):
446446
if self._secondary_synchronizer_builder is None:
447447
continue
448448

449-
with self._lock.write_lock():
449+
with self._lock.write():
450450
secondary_sync = self._secondary_synchronizer_builder(self._config)
451451
if isinstance(secondary_sync, DiagnosticSource) and self._diagnostic_accumulator is not None:
452452
secondary_sync.set_diagnostic_accumulator(self._diagnostic_accumulator)
@@ -480,7 +480,7 @@ def synchronizer_loop(self: 'FDv2'):
480480
finally:
481481
# Ensure we always set the ready event when exiting
482482
set_on_ready.set()
483-
with self._lock.write_lock():
483+
with self._lock.write():
484484
if self._active_synchronizer is not None:
485485
self._active_synchronizer.stop()
486486
self._active_synchronizer = None

ldclient/impl/datasystem/store.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def get(
4949
key: str,
5050
callback: Callable[[Any], Any] = lambda x: x,
5151
) -> Any:
52-
with self._lock.read_lock():
52+
with self._lock.read():
5353
items_of_kind = self._items[kind]
5454
item = items_of_kind.get(key)
5555
if item is None:
@@ -69,7 +69,7 @@ def get(
6969
return callback(item)
7070

7171
def all(self, kind: VersionedDataKind, callback: Callable[[Any], Any] = lambda x: x) -> Any:
72-
with self._lock.read_lock():
72+
with self._lock.read():
7373
items_of_kind = self._items[kind]
7474
return callback(
7575
dict(
@@ -88,7 +88,7 @@ def set_basis(self, collections: Collections) -> bool:
8888
return False
8989

9090
try:
91-
with self._lock.write_lock():
91+
with self._lock.write():
9292
self._items.clear()
9393
self._items.update(all_decoded)
9494
self._initialized = True
@@ -107,7 +107,7 @@ def apply_delta(self, collections: Collections) -> bool:
107107
return False
108108

109109
try:
110-
with self._lock.write_lock():
110+
with self._lock.write():
111111
for kind, kind_data in all_decoded.items():
112112
items_of_kind = self._items[kind]
113113
kind_data = all_decoded[kind]
@@ -142,7 +142,7 @@ def initialized(self) -> bool:
142142
"""
143143
Indicates whether the store has been initialized with data.
144144
"""
145-
with self._lock.read_lock():
145+
with self._lock.read():
146146
return self._initialized
147147

148148

@@ -212,7 +212,7 @@ def with_persistence(
212212
Returns:
213213
Self for method chaining
214214
"""
215-
with self._lock.write_lock():
215+
with self._lock.write():
216216
self._persistent_store = persistent_store
217217
self._persistent_store_writable = writable
218218
self._persistent_store_status_provider = status_provider
@@ -224,12 +224,12 @@ def with_persistence(
224224

225225
def selector(self) -> Selector:
226226
"""Returns the current selector."""
227-
with self._lock.read_lock():
227+
with self._lock.read():
228228
return self._selector
229229

230230
def close(self) -> Optional[Exception]:
231231
"""Close the store and any persistent store if configured."""
232-
with self._lock.write_lock():
232+
with self._lock.write():
233233
if self._persistent_store is not None:
234234
try:
235235
# Most FeatureStore implementations don't have close methods
@@ -250,7 +250,7 @@ def apply(self, change_set: ChangeSet, persist: bool) -> None:
250250
"""
251251
collections = self._changes_to_store_data(change_set.changes)
252252

253-
with self._lock.write_lock():
253+
with self._lock.write():
254254
try:
255255
if change_set.intent_code == IntentCode.TRANSFER_FULL:
256256
self._set_basis(collections, change_set.selector, persist)
@@ -442,7 +442,7 @@ def __mapping(data: Dict[str, ModelEntity]) -> Dict[str, Dict[str, Any]]:
442442

443443
return __mapping
444444

445-
with self._lock.write_lock():
445+
with self._lock.write():
446446
if self._should_persist():
447447
try:
448448
# Get all data from memory store and write to persistent store
@@ -456,7 +456,7 @@ def __mapping(data: Dict[str, ModelEntity]) -> Dict[str, Dict[str, Any]]:
456456

457457
def get_active_store(self) -> ReadOnlyStore:
458458
"""Get the currently active store for reading data."""
459-
with self._lock.read_lock():
459+
with self._lock.read():
460460
return self._active_store
461461

462462
def is_initialized(self) -> bool:
@@ -465,5 +465,5 @@ def is_initialized(self) -> bool:
465465

466466
def get_data_store_status_provider(self) -> Optional[DataStoreStatusProvider]:
467467
"""Get the data store status provider for the persistent store, if configured."""
468-
with self._lock.read_lock():
468+
with self._lock.read():
469469
return self._persistent_store_status_provider

ldclient/impl/flag_tracker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def __call__(self, flag_change: FlagChange):
2222

2323
new_value = self.__eval_fn(self.__key, self.__context)
2424

25-
with self.__lock.write_lock():
25+
with self.__lock.write():
2626
old_value, self.__value = self.__value, new_value
2727

2828
if new_value == old_value:

ldclient/impl/listeners.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,22 @@ def __init__(self):
1515
self.__lock = ReadWriteLock()
1616

1717
def has_listeners(self) -> bool:
18-
with self.__lock.read_lock():
18+
with self.__lock.read():
1919
return len(self.__listeners) > 0
2020

2121
def add(self, listener: Callable):
22-
with self.__lock.write_lock():
22+
with self.__lock.write():
2323
self.__listeners.append(listener)
2424

2525
def remove(self, listener: Callable):
26-
with self.__lock.write_lock():
26+
with self.__lock.write():
2727
try:
2828
self.__listeners.remove(listener)
2929
except ValueError:
3030
pass # removing a listener that wasn't in the list is a no-op
3131

3232
def notify(self, value: Any):
33-
with self.__lock.read_lock():
33+
with self.__lock.read():
3434
listeners_copy = self.__listeners.copy()
3535
for listener in listeners_copy:
3636
try:

0 commit comments

Comments
 (0)