Rename Model._write_lock → Model.write_lock

This commit is contained in:
miruka 2020-05-28 14:13:14 -04:00
parent 0f6f3bce98
commit c0118c4e28
3 changed files with 5 additions and 5 deletions

View File

@ -77,7 +77,7 @@ class ModelFilter(ModelProxy):
) -> None: ) -> None:
"""Recheck every item to decide if they should be filtered out.""" """Recheck every item to decide if they should be filtered out."""
with self._write_lock: with self.write_lock:
take_out = [] take_out = []
bring_back = [] bring_back = []

View File

@ -39,9 +39,9 @@ class Model(MutableMapping):
def __init__(self, sync_id: Optional[SyncId]) -> None: def __init__(self, sync_id: Optional[SyncId]) -> None:
self.sync_id: Optional[SyncId] = sync_id self.sync_id: Optional[SyncId] = sync_id
self.write_lock: RLock = RLock()
self._data: Dict[Any, "ModelItem"] = {} self._data: Dict[Any, "ModelItem"] = {}
self._sorted_data: List["ModelItem"] = blist() self._sorted_data: List["ModelItem"] = blist()
self._write_lock: RLock = RLock()
self.take_items_ownership: bool = True self.take_items_ownership: bool = True
@ -79,7 +79,7 @@ class Model(MutableMapping):
value: "ModelItem", value: "ModelItem",
_changed_fields: Optional[Dict[str, Any]] = None, _changed_fields: Optional[Dict[str, Any]] = None,
) -> None: ) -> None:
with self._write_lock: with self.write_lock:
existing = self._data.get(key) existing = self._data.get(key)
new = value new = value
@ -133,7 +133,7 @@ class Model(MutableMapping):
def __delitem__(self, key) -> None: def __delitem__(self, key) -> None:
with self._write_lock: with self.write_lock:
item = self._data[key] item = self._data[key]
if self.sync_id and self.take_items_ownership: if self.sync_id and self.take_items_ownership:

View File

@ -49,7 +49,7 @@ class ModelItem:
fields = {name: self.serialize_field(name)} fields = {name: self.serialize_field(name)}
with parent._write_lock: with parent.write_lock:
index_then = parent._sorted_data.index(self) index_then = parent._sorted_data.index(self)
parent._sorted_data.sort() parent._sorted_data.sort()
index_now = parent._sorted_data.index(self) index_now = parent._sorted_data.index(self)