From f110a261b9983c77d71d63c6568f1207c6e18667 Mon Sep 17 00:00:00 2001 From: mrdrup Date: Sat, 19 Jun 2021 13:15:02 +0100 Subject: [PATCH] Fix 'FileExistsError' shared memory exception (#945) --- frigate/app.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/frigate/app.py b/frigate/app.py index 1e000d401..a6994d6d9 100644 --- a/frigate/app.py +++ b/frigate/app.py @@ -180,14 +180,23 @@ class FrigateApp: model_shape = (self.config.model.height, self.config.model.width) for name in self.config.cameras.keys(): self.detection_out_events[name] = mp.Event() - shm_in = mp.shared_memory.SharedMemory( - name=name, - create=True, - size=self.config.model.height * self.config.model.width * 3, - ) - shm_out = mp.shared_memory.SharedMemory( - name=f"out-{name}", create=True, size=20 * 6 * 4 - ) + + try: + shm_in = mp.shared_memory.SharedMemory( + name=name, + create=True, + size=self.config.model.height*self.config.model.width * 3, + ) + except FileExistsError: + shm_in = mp.shared_memory.SharedMemory(name=name) + + try: + shm_out = mp.shared_memory.SharedMemory( + name=f"out-{name}", create=True, size=20 * 6 * 4 + ) + except FileExistsError: + shm_out = mp.shared_memory.SharedMemory(name=f"out-{name}") + self.detection_shms.append(shm_in) self.detection_shms.append(shm_out)