Fix 'FileExistsError' shared memory exception

This commit is contained in:
mr.dr.up 2021-03-28 20:43:37 +01:00
parent d2bc2c20c1
commit 5312df0f34

View File

@ -146,10 +146,16 @@ class FrigateApp():
model_shape = (self.config.model.height, self.config.model.width) model_shape = (self.config.model.height, self.config.model.width)
for name in self.config.cameras.keys(): for name in self.config.cameras.keys():
self.detection_out_events[name] = mp.Event() 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:
self.detection_shms.append(shm_in) self.detection_shms.append(mp.shared_memory.SharedMemory(name=name, create=True, size=self.config.model.height*self.config.model.width*3))
self.detection_shms.append(shm_out) except FileExistsError:
self.detection_shms.append(mp.shared_memory.SharedMemory(name=name))
try:
self.detection_shms.append(mp.shared_memory.SharedMemory(name=f"out-{name}", create=True, size=20*6*4))
except FileExistsError:
self.detection_shms.append(mp.shared_memory.SharedMemory(name=f"out-{name}"))
for name, detector in self.config.detectors.items(): for name, detector in self.config.detectors.items():
if detector.type == 'cpu': if detector.type == 'cpu':