From: Scott Gasch Date: Thu, 3 Feb 2022 22:04:07 +0000 (-0800) Subject: Take the lock before unlinking the mmap'ed shared memory to ensure X-Git-Url: https://wannabe.guru.org/gitweb/?a=commitdiff_plain;h=eb1c6392095947b3205c4d52cd9b1507e6cd776b;hp=ffed473528c4feb836253758e86f7839af98f57b;p=python_utils.git Take the lock before unlinking the mmap'ed shared memory to ensure all writes are finished and visible. --- diff --git a/collect/shared_dict.py b/collect/shared_dict.py index ac390bc..ec76138 100644 --- a/collect/shared_dict.py +++ b/collect/shared_dict.py @@ -108,7 +108,8 @@ class SharedDict(object): def cleanup(self) -> None: if not hasattr(self, 'shared_memory'): return - self.shared_memory.unlink() + with SharedDict.MPLOCK: + self.shared_memory.unlink() def clear(self) -> None: self._save_memory({})