mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-06 11:15:21 +03:00
Refactor import statements in frigate/events.py and frigate/record.py to use faster_fifo library instead of multiprocessing
This commit is contained in:
parent
6b0a68d0dd
commit
44a2453f12
@ -13,7 +13,7 @@ from frigate.const import CLIPS_DIR
|
|||||||
from frigate.models import Event
|
from frigate.models import Event
|
||||||
from frigate.types import CameraMetricsTypes
|
from frigate.types import CameraMetricsTypes
|
||||||
|
|
||||||
from multiprocessing.queues import Queue
|
from faster_fifo import Queue
|
||||||
from multiprocessing.synchronize import Event as MpEvent
|
from multiprocessing.synchronize import Event as MpEvent
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
|
|
||||||
|
|||||||
@ -10,6 +10,7 @@ import subprocess as sp
|
|||||||
import threading
|
import threading
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
import faster_fifo as ff
|
||||||
|
|
||||||
import psutil
|
import psutil
|
||||||
from peewee import JOIN, DoesNotExist
|
from peewee import JOIN, DoesNotExist
|
||||||
@ -42,7 +43,7 @@ def remove_empty_directories(directory):
|
|||||||
|
|
||||||
class RecordingMaintainer(threading.Thread):
|
class RecordingMaintainer(threading.Thread):
|
||||||
def __init__(
|
def __init__(
|
||||||
self, config: FrigateConfig, recordings_info_queue: mp.Queue, stop_event
|
self, config: FrigateConfig, recordings_info_queue: ff.Queue, stop_event
|
||||||
):
|
):
|
||||||
threading.Thread.__init__(self)
|
threading.Thread.__init__(self)
|
||||||
self.name = "recording_maint"
|
self.name = "recording_maint"
|
||||||
@ -111,7 +112,6 @@ class RecordingMaintainer(threading.Thread):
|
|||||||
grouped_recordings[camera] = grouped_recordings[camera][-keep_count:]
|
grouped_recordings[camera] = grouped_recordings[camera][-keep_count:]
|
||||||
|
|
||||||
for camera, recordings in grouped_recordings.items():
|
for camera, recordings in grouped_recordings.items():
|
||||||
|
|
||||||
# clear out all the recording info for old frames
|
# clear out all the recording info for old frames
|
||||||
while (
|
while (
|
||||||
len(self.recordings_info[camera]) > 0
|
len(self.recordings_info[camera]) > 0
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import subprocess as sp
|
|||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
import signal
|
import signal
|
||||||
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
import yaml
|
import yaml
|
||||||
@ -14,7 +15,7 @@ import yaml
|
|||||||
from abc import ABC, abstractmethod
|
from abc import ABC, abstractmethod
|
||||||
from collections import Counter
|
from collections import Counter
|
||||||
from collections.abc import Mapping
|
from collections.abc import Mapping
|
||||||
from multiprocessing import shared_memory
|
from multiprocessing import shared_memory, RawValue
|
||||||
from queue import Empty, Full
|
from queue import Empty, Full
|
||||||
from typing import Any, AnyStr, Optional, Tuple
|
from typing import Any, AnyStr, Optional, Tuple
|
||||||
|
|
||||||
@ -1081,7 +1082,7 @@ class LimitedQueue(FFQueue):
|
|||||||
):
|
):
|
||||||
super().__init__(max_size_bytes=max_size_bytes, loads=loads, dumps=dumps)
|
super().__init__(max_size_bytes=max_size_bytes, loads=loads, dumps=dumps)
|
||||||
self.maxsize = maxsize
|
self.maxsize = maxsize
|
||||||
self.size = multiprocessing.RawValue(
|
self.size = RawValue(
|
||||||
ctypes.c_int, 0
|
ctypes.c_int, 0
|
||||||
) # Add a counter for the number of items in the queue
|
) # Add a counter for the number of items in the queue
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user