mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-08-04 13:47:37 +02:00
Cleanup inter process typing issues
This commit is contained in:
parent
aabab5e5ef
commit
81d52bcec6
@ -1,5 +1,6 @@
|
|||||||
"""Facilitates communication between processes."""
|
"""Facilitates communication between processes."""
|
||||||
|
|
||||||
|
import logging
|
||||||
import multiprocessing as mp
|
import multiprocessing as mp
|
||||||
import threading
|
import threading
|
||||||
from multiprocessing.synchronize import Event as MpEvent
|
from multiprocessing.synchronize import Event as MpEvent
|
||||||
@ -9,6 +10,8 @@ import zmq
|
|||||||
|
|
||||||
from frigate.comms.base_communicator import Communicator
|
from frigate.comms.base_communicator import Communicator
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
SOCKET_REP_REQ = "ipc:///tmp/cache/comms"
|
SOCKET_REP_REQ = "ipc:///tmp/cache/comms"
|
||||||
|
|
||||||
|
|
||||||
@ -19,7 +22,7 @@ class InterProcessCommunicator(Communicator):
|
|||||||
self.socket.bind(SOCKET_REP_REQ)
|
self.socket.bind(SOCKET_REP_REQ)
|
||||||
self.stop_event: MpEvent = mp.Event()
|
self.stop_event: MpEvent = mp.Event()
|
||||||
|
|
||||||
def publish(self, topic: str, payload: str, retain: bool) -> None:
|
def publish(self, topic: str, payload: Any, retain: bool = False) -> None:
|
||||||
"""There is no communication back to the processes."""
|
"""There is no communication back to the processes."""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -37,9 +40,16 @@ class InterProcessCommunicator(Communicator):
|
|||||||
break
|
break
|
||||||
|
|
||||||
try:
|
try:
|
||||||
(topic, value) = self.socket.recv_json(flags=zmq.NOBLOCK)
|
raw = self.socket.recv_json(flags=zmq.NOBLOCK)
|
||||||
|
|
||||||
response = self._dispatcher(topic, value)
|
if isinstance(raw, list):
|
||||||
|
(topic, value) = raw
|
||||||
|
response = self._dispatcher(topic, value)
|
||||||
|
else:
|
||||||
|
logging.warning(
|
||||||
|
f"Received unexpected data type in ZMQ inter-process: {type(raw)}"
|
||||||
|
)
|
||||||
|
response = None
|
||||||
|
|
||||||
if response is not None:
|
if response is not None:
|
||||||
self.socket.send_json(response)
|
self.socket.send_json(response)
|
||||||
|
Loading…
Reference in New Issue
Block a user