66ChangeSet applications and flag change notifications.
77"""
88
9+ import threading
910from collections import defaultdict
1011from typing import Any , Callable , Dict , List , Optional , Set
1112
@@ -193,7 +194,7 @@ def __init__(
193194 self ._selector = Selector .no_selector ()
194195
195196 # Thread synchronization
196- self ._lock = ReadWriteLock ()
197+ self ._lock = threading . RLock ()
197198
198199 def with_persistence (
199200 self ,
@@ -212,7 +213,7 @@ def with_persistence(
212213 Returns:
213214 Self for method chaining
214215 """
215- with self ._lock . write () :
216+ with self ._lock :
216217 self ._persistent_store = persistent_store
217218 self ._persistent_store_writable = writable
218219 self ._persistent_store_status_provider = status_provider
@@ -224,12 +225,12 @@ def with_persistence(
224225
225226 def selector (self ) -> Selector :
226227 """Returns the current selector."""
227- with self ._lock . read () :
228+ with self ._lock :
228229 return self ._selector
229230
230231 def close (self ) -> Optional [Exception ]:
231232 """Close the store and any persistent store if configured."""
232- with self ._lock . write () :
233+ with self ._lock :
233234 if self ._persistent_store is not None :
234235 try :
235236 # Most FeatureStore implementations don't have close methods
@@ -250,7 +251,7 @@ def apply(self, change_set: ChangeSet, persist: bool) -> None:
250251 """
251252 collections = self ._changes_to_store_data (change_set .changes )
252253
253- with self ._lock . write () :
254+ with self ._lock :
254255 try :
255256 if change_set .intent_code == IntentCode .TRANSFER_FULL :
256257 self ._set_basis (collections , change_set .selector , persist )
@@ -442,7 +443,7 @@ def __mapping(data: Dict[str, ModelEntity]) -> Dict[str, Dict[str, Any]]:
442443
443444 return __mapping
444445
445- with self ._lock . write () :
446+ with self ._lock :
446447 if self ._should_persist ():
447448 try :
448449 # Get all data from memory store and write to persistent store
@@ -456,7 +457,7 @@ def __mapping(data: Dict[str, ModelEntity]) -> Dict[str, Dict[str, Any]]:
456457
457458 def get_active_store (self ) -> ReadOnlyStore :
458459 """Get the currently active store for reading data."""
459- with self ._lock . read () :
460+ with self ._lock :
460461 return self ._active_store
461462
462463 def is_initialized (self ) -> bool :
@@ -465,5 +466,5 @@ def is_initialized(self) -> bool:
465466
466467 def get_data_store_status_provider (self ) -> Optional [DataStoreStatusProvider ]:
467468 """Get the data store status provider for the persistent store, if configured."""
468- with self ._lock . read () :
469+ with self ._lock :
469470 return self ._persistent_store_status_provider
0 commit comments