Fix 'FileExistsError' shared memory exception (#945)

This commit is contained in:
mrdrup 2021-06-19 13:15:02 +01:00 committed by GitHub
parent b72b66781a
commit f110a261b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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()
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)