Skip to content

Commit

Permalink
Sort out Event disambiguity
Browse files Browse the repository at this point in the history
There was a name collision of multiprocessing Event type and frigate events
  • Loading branch information
herostrat committed Nov 18, 2022
1 parent 6929db0 commit 4d6de35
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
6 changes: 3 additions & 3 deletions frigate/app.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
import multiprocessing as mp
from multiprocessing.queues import Queue
from multiprocessing.synchronize import Event
from multiprocessing.synchronize import Event as MpEvent
import os
import signal
import sys
Expand Down Expand Up @@ -38,10 +38,10 @@

class FrigateApp:
def __init__(self) -> None:
self.stop_event: Event = mp.Event()
self.stop_event: MpEvent = mp.Event()
self.detection_queue: Queue = mp.Queue()
self.detectors: dict[str, ObjectDetectProcess] = {}
self.detection_out_events: dict[str, Event] = {}
self.detection_out_events: dict[str, MpEvent] = {}
self.detection_shms: list[mp.shared_memory.SharedMemory] = []
self.log_queue: Queue = mp.Queue()
self.plus_api = PlusApi()
Expand Down
5 changes: 3 additions & 2 deletions frigate/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from frigate.types import CameraMetricsTypes

from multiprocessing.queues import Queue
from multiprocessing.synchronize import Event as MpEvent
from typing import Dict

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -47,7 +48,7 @@ def __init__(
camera_processes: dict[str, CameraMetricsTypes],
event_queue: Queue,
event_processed_queue: Queue,
stop_event: Event,
stop_event: MpEvent,
):
threading.Thread.__init__(self)
self.name = "event_processor"
Expand Down Expand Up @@ -158,7 +159,7 @@ def run(self) -> None:


class EventCleanup(threading.Thread):
def __init__(self, config: FrigateConfig, stop_event: Event):
def __init__(self, config: FrigateConfig, stop_event: MpEvent):
threading.Thread.__init__(self)
self.name = "event_cleanup"
self.config = config
Expand Down
4 changes: 2 additions & 2 deletions frigate/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import requests
from typing import Optional, Any
from paho.mqtt.client import Client
from multiprocessing.synchronize import Event
from multiprocessing.synchronize import Event as MpEvent

from frigate.config import FrigateConfig
from frigate.const import RECORD_DIR, CLIPS_DIR, CACHE_DIR
Expand Down Expand Up @@ -148,7 +148,7 @@ def __init__(
stats_tracking: StatsTrackingTypes,
mqtt_client: Client,
topic_prefix: str,
stop_event: Event,
stop_event: MpEvent,
):
threading.Thread.__init__(self)
self.name = "frigate_stats_emitter"
Expand Down
4 changes: 2 additions & 2 deletions frigate/watchdog.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

from frigate.object_detection import ObjectDetectProcess
from frigate.util import restart_frigate
from multiprocessing.synchronize import Event
from multiprocessing.synchronize import Event as MpEvent

logger = logging.getLogger(__name__)


class FrigateWatchdog(threading.Thread):
def __init__(self, detectors: dict[str, ObjectDetectProcess], stop_event: Event):
def __init__(self, detectors: dict[str, ObjectDetectProcess], stop_event: MpEvent):
threading.Thread.__init__(self)
self.name = "frigate_watchdog"
self.detectors = detectors
Expand Down

0 comments on commit 4d6de35

Please sign in to comment.