From c0118c4e288b7ee8807a9b6ec9cfbb47ea9bcaae Mon Sep 17 00:00:00 2001 From: miruka Date: Thu, 28 May 2020 14:13:14 -0400 Subject: [PATCH] =?UTF-8?q?Rename=20Model.=5Fwrite=5Flock=20=E2=86=92=20Mo?= =?UTF-8?q?del.write=5Flock?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/backend/models/filters.py | 2 +- src/backend/models/model.py | 6 +++--- src/backend/models/model_item.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/backend/models/filters.py b/src/backend/models/filters.py index eebfabae..0c9a2439 100644 --- a/src/backend/models/filters.py +++ b/src/backend/models/filters.py @@ -77,7 +77,7 @@ class ModelFilter(ModelProxy): ) -> None: """Recheck every item to decide if they should be filtered out.""" - with self._write_lock: + with self.write_lock: take_out = [] bring_back = [] diff --git a/src/backend/models/model.py b/src/backend/models/model.py index a7d08127..adbd4a29 100644 --- a/src/backend/models/model.py +++ b/src/backend/models/model.py @@ -39,9 +39,9 @@ class Model(MutableMapping): def __init__(self, sync_id: Optional[SyncId]) -> None: self.sync_id: Optional[SyncId] = sync_id + self.write_lock: RLock = RLock() self._data: Dict[Any, "ModelItem"] = {} self._sorted_data: List["ModelItem"] = blist() - self._write_lock: RLock = RLock() self.take_items_ownership: bool = True @@ -79,7 +79,7 @@ class Model(MutableMapping): value: "ModelItem", _changed_fields: Optional[Dict[str, Any]] = None, ) -> None: - with self._write_lock: + with self.write_lock: existing = self._data.get(key) new = value @@ -133,7 +133,7 @@ class Model(MutableMapping): def __delitem__(self, key) -> None: - with self._write_lock: + with self.write_lock: item = self._data[key] if self.sync_id and self.take_items_ownership: diff --git a/src/backend/models/model_item.py b/src/backend/models/model_item.py index e65249cf..234087a6 100644 --- a/src/backend/models/model_item.py +++ b/src/backend/models/model_item.py @@ -49,7 +49,7 @@ class ModelItem: fields = {name: self.serialize_field(name)} - with parent._write_lock: + with parent.write_lock: index_then = parent._sorted_data.index(self) parent._sorted_data.sort() index_now = parent._sorted_data.index(self)