home · contact · privacy
On cache emptying, also ._disappear() any objects held in it.
authorChristian Heller <c.heller@plomlompom.de>
Mon, 17 Jun 2024 23:03:19 +0000 (01:03 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Mon, 17 Jun 2024 23:03:19 +0000 (01:03 +0200)
plomtask/db.py

index 3917ce0558e3f7deb1f917a07eb5dd4df7b279e6..385e79855286c45087537b3b63b8b024fd553ca0 100644 (file)
@@ -315,7 +315,13 @@ class BaseModel(Generic[BaseModelId]):
 
     @classmethod
     def empty_cache(cls) -> None:
-        """Empty class's cache."""
+        """Empty class's cache, and disappear all former inhabitants."""
+        # pylint: disable=protected-access
+        # (cause we remain within the class)
+        if hasattr(cls, 'cache_'):
+            to_disappear = list(cls.cache_.values())
+            for item in to_disappear:
+                item._disappear()
         cls.cache_ = {}
 
     @classmethod