AareGUI: Smoothen exit from GUI by adding timeout on ZeroMQ

This commit is contained in:
2025-09-25 09:12:59 +02:00
parent b116641d9f
commit f2ff0e04aa
2 changed files with 4 additions and 4 deletions
+1 -3
View File
@@ -28,7 +28,7 @@ class VideoThread(QThread):
self.session = requests.Session()
# Set connection timeout and read timeout
timeout = (5, 30) # (connect_timeout, read_timeout)
timeout = (1, 3) # (connect_timeout, read_timeout)
try:
# Start streaming
@@ -124,10 +124,8 @@ class VideoThread(QThread):
def stop(self):
self.running = False
print("Video thread stop requested")
if self.session:
self.session.close()
self.quit()
print("Video thread stopped. Exiting...")
self.wait()
+3 -1
View File
@@ -16,6 +16,7 @@ class SampleCameraThread(QThread):
context = zmq.Context()
self.__socket = context.socket(zmq.SUB)
self.__socket.setsockopt(zmq.SUBSCRIBE, b"")
self.__socket.setsockopt(zmq.RCVTIMEO, 500)
self.__socket.connect(zmq_url)
self.running = True
@@ -40,6 +41,8 @@ class SampleCameraThread(QThread):
self.camera_image.emit(QPixmap.fromImage(qimage))
else:
print("Sample camera image has wrong dimensions")
except zmq.Again: # Timeout occurred
continue # Check self.running again
except Exception as e:
print(f"Error in sample camera thread {e}")
@@ -50,5 +53,4 @@ class SampleCameraThread(QThread):
if self.__socket:
self.__socket.close()
self.quit()
print("Camera thread stopped. Exiting...")
self.wait()