mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-07-05 19:41:15 +03:00
use setdefault when adding a new camera
Multiple subscribers in the same process each unpickle the ZMQ payload independently and would otherwise write divergent Python objects to the shared cameras dict — leaving long-lived references (e.g. CameraState.camera_config) pointing at a copy that subsequent in-place mutations like apply_section_update can never reach. setdefault collapses everyone onto the first writer's object so attribute mutations propagate to every consumer in this process.
This commit is contained in:
parent
50dee829cf
commit
a4868184d4
@ -84,8 +84,8 @@ class CameraConfigUpdateSubscriber:
|
|||||||
self, camera: str, update_type: CameraConfigUpdateEnum, updated_config: Any
|
self, camera: str, update_type: CameraConfigUpdateEnum, updated_config: Any
|
||||||
) -> None:
|
) -> None:
|
||||||
if update_type == CameraConfigUpdateEnum.add:
|
if update_type == CameraConfigUpdateEnum.add:
|
||||||
self.config.cameras[camera] = updated_config
|
shared = self.config.cameras.setdefault(camera, updated_config)
|
||||||
self.camera_configs[camera] = updated_config
|
self.camera_configs[camera] = shared
|
||||||
return
|
return
|
||||||
elif update_type == CameraConfigUpdateEnum.remove:
|
elif update_type == CameraConfigUpdateEnum.remove:
|
||||||
self.config.cameras.pop(camera, None)
|
self.config.cameras.pop(camera, None)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user