Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
# Write repository
- async def write(self, *args, **kwargs):
+ __locks = {}
+
+ @property
+ def __lock(self):
+ try:
+ lock = self.__locks[self.id]
+ except KeyError:
+ lock = self.__locks[self.id] = asyncio.Lock()
+
+ return lock
+
+ async def write(self):
"""
Called to write/rewrite/update the repository metadata
"""
- return await asyncio.to_thread(self._write, *args, **kwargs)
+ with self.__lock:
+ return await asyncio.to_thread(self._write)
def _write(self):
log.info("Writing repository %s..." % self)