Skip to content

Commit 97a8e1c

Browse files
committed
Add timeout for recorder stop retries
Introduce a configurable `RECORD_STOP_RETRY_TIMEOUT` in `config.py` and enforce it in the recording stop worker. The stop loop now tracks cumulative wait time, logs a timeout error, and raises a runtime error if recorders cannot be stopped within the configured limit, preventing indefinite retry loops during shutdown.
1 parent 68e6e17 commit 97a8e1c

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

‎dlclivegui/config.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
ALLOWED_VIDEO_CONTAINERS: set[str] = {"mp4", "avi", "mov"}
2929
DEFAULT_RECORDING_CONTAINER: str = "mp4"
3030
RECORD_STOP_RETRY_INTERVAL: float = 0.25
31+
RECORD_STOP_RETRY_TIMEOUT: float = 5.0
3132

3233

3334
## Debug

‎dlclivegui/gui/main_window.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
DLC_DO_LOG_TIMING,
5656
GUI_MAX_DISPLAY_FPS,
5757
RECORD_STOP_RETRY_INTERVAL,
58+
RECORD_STOP_RETRY_TIMEOUT,
5859
ApplicationSettings,
5960
BoundingBoxSettings,
6061
CameraSettings,
@@ -1652,10 +1653,15 @@ def _stop_multi_camera_recording(self) -> None:
16521653
logger.exception("Failed to disable recording frame emission")
16531654

16541655
def worker():
1656+
total_wait_time = 0.0
16551657
try:
16561658
while not self._rec_manager.stop_all():
16571659
logger.info("Retrying recorder stop...")
16581660
time.sleep(RECORD_STOP_RETRY_INTERVAL)
1661+
total_wait_time += RECORD_STOP_RETRY_INTERVAL
1662+
if total_wait_time >= RECORD_STOP_RETRY_TIMEOUT:
1663+
logger.error("Timeout while stopping recording after %.1f seconds", total_wait_time)
1664+
raise RuntimeError("Could not stop recording within timeout period.")
16591665
except Exception as e:
16601666
logger.exception("Error while stopping recording: %s", e)
16611667
return

0 commit comments

Comments
 (0)