mirror of
https://github.com/huggingface/lerobot.git
synced 2026-07-24 10:16:09 +00:00
fix(stop_event): fixing stop_event race condition in camera classes
This commit is contained in:
@@ -436,7 +436,7 @@ class OpenCVCamera(Camera):
|
|||||||
Internal loop run by the background thread for asynchronous reading.
|
Internal loop run by the background thread for asynchronous reading.
|
||||||
|
|
||||||
On each iteration:
|
On each iteration:
|
||||||
1. Reads a color frame
|
1. Reads a color frame (blocking call)
|
||||||
2. Stores result in latest_frame and updates timestamp (thread-safe)
|
2. Stores result in latest_frame and updates timestamp (thread-safe)
|
||||||
3. Sets new_frame_event to notify listeners
|
3. Sets new_frame_event to notify listeners
|
||||||
|
|
||||||
@@ -485,6 +485,8 @@ class OpenCVCamera(Camera):
|
|||||||
|
|
||||||
if self.thread is not None and self.thread.is_alive():
|
if self.thread is not None and self.thread.is_alive():
|
||||||
self.thread.join(timeout=2.0)
|
self.thread.join(timeout=2.0)
|
||||||
|
if self.thread.is_alive():
|
||||||
|
logger.warning(f"{self} read thread did not terminate within timeout.")
|
||||||
|
|
||||||
self.thread = None
|
self.thread = None
|
||||||
self.stop_event = None
|
self.stop_event = None
|
||||||
|
|||||||
@@ -465,8 +465,8 @@ class RealSenseCamera(Camera):
|
|||||||
Internal loop run by the background thread for asynchronous reading.
|
Internal loop run by the background thread for asynchronous reading.
|
||||||
|
|
||||||
On each iteration:
|
On each iteration:
|
||||||
1. Reads a color frame with 500ms timeout
|
1. Reads a color/depth frame (blocking call with 10s timeout)
|
||||||
2. Stores result in latest_frame and updates timestamp (thread-safe)
|
2. Stores result in latest_color_frame/latest_depth_frame and updates timestamp (thread-safe)
|
||||||
3. Sets new_frame_event to notify listeners
|
3. Sets new_frame_event to notify listeners
|
||||||
|
|
||||||
Stops on DeviceNotConnectedError, logs other errors and continues.
|
Stops on DeviceNotConnectedError, logs other errors and continues.
|
||||||
@@ -525,6 +525,8 @@ class RealSenseCamera(Camera):
|
|||||||
|
|
||||||
if self.thread is not None and self.thread.is_alive():
|
if self.thread is not None and self.thread.is_alive():
|
||||||
self.thread.join(timeout=2.0)
|
self.thread.join(timeout=2.0)
|
||||||
|
if self.thread.is_alive(): # pragma: no cover
|
||||||
|
logger.warning(f"{self} read thread did not terminate within timeout.")
|
||||||
|
|
||||||
self.thread = None
|
self.thread = None
|
||||||
self.stop_event = None
|
self.stop_event = None
|
||||||
|
|||||||
@@ -293,6 +293,8 @@ class ZMQCamera(Camera):
|
|||||||
|
|
||||||
if self.thread is not None and self.thread.is_alive():
|
if self.thread is not None and self.thread.is_alive():
|
||||||
self.thread.join(timeout=2.0)
|
self.thread.join(timeout=2.0)
|
||||||
|
if self.thread.is_alive():
|
||||||
|
logger.warning(f"{self} read thread did not terminate within timeout.")
|
||||||
|
|
||||||
self.thread = None
|
self.thread = None
|
||||||
self.stop_event = None
|
self.stop_event = None
|
||||||
|
|||||||
Reference in New Issue
Block a user