style: replace dunder attributes with normal 'private' attrs
This commit is contained in:
1 parent
660a0acf7c
commit
fb0c8efebe
48 files changed
+1939
-1952
No files matched your search
@@ -1,23 +1,24 @@
|
||||
import json
|
||||
import threading
|
||||
import time
|
||||
from typing import Any, Dict
|
||||
|
||||
import cv2
|
||||
import numpy as np
|
||||
import zmq
|
||||
import time
|
||||
import threading
|
||||
from typing import Dict, Any
|
||||
|
||||
|
||||
class ImageStatsReceiver:
|
||||
def __init__(self, zmq_url: str):
|
||||
"""Initialize ZeroMQ receiver for image statistics calculation"""
|
||||
context = zmq.Context()
|
||||
self.__socket = context.socket(zmq.SUB)
|
||||
self.__socket.setsockopt(zmq.SUBSCRIBE, b"")
|
||||
self.__socket.setsockopt(zmq.RCVTIMEO, 1000) # 1 second timeout
|
||||
self.__socket.setsockopt(zmq.LINGER, 0) # Don't linger on close
|
||||
self._socket = context.socket(zmq.SUB)
|
||||
self._socket.setsockopt(zmq.SUBSCRIBE, b"")
|
||||
self._socket.setsockopt(zmq.RCVTIMEO, 1000) # 1 second timeout
|
||||
self._socket.setsockopt(zmq.LINGER, 0) # Don't linger on close
|
||||
|
||||
try:
|
||||
self.__socket.connect(zmq_url)
|
||||
self._socket.connect(zmq_url)
|
||||
print(f"Connected to ZeroMQ socket: {zmq_url}")
|
||||
except Exception as e:
|
||||
print(f"Failed to connect to {zmq_url}: {e}")
|
||||
@@ -187,7 +188,7 @@ class ImageStatsReceiver:
|
||||
def process_message(self):
|
||||
"""Process a single ZeroMQ message"""
|
||||
try:
|
||||
r = self.__socket.recv_multipart(zmq.NOBLOCK)
|
||||
r = self._socket.recv_multipart(zmq.NOBLOCK)
|
||||
if len(r) != 2:
|
||||
return None
|
||||
|
||||
@@ -373,8 +374,8 @@ class ImageStatsReceiver:
|
||||
def stop(self):
|
||||
"""Stop the receiver and all threads"""
|
||||
self.running = False
|
||||
if self.__socket:
|
||||
self.__socket.close()
|
||||
if self._socket:
|
||||
self._socket.close()
|
||||
print("Image stats receiver stopped")
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user