From e6553065fdc04897b80fed6b4b372b166528f1ce Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Mon, 5 Jan 2026 10:31:17 +0100 Subject: [PATCH] API - Watch get, retry watch data if watch dict changed (more reliable) --- changedetectionio/api/Watch.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/changedetectionio/api/Watch.py b/changedetectionio/api/Watch.py index 82173842e..390599c4a 100644 --- a/changedetectionio/api/Watch.py +++ b/changedetectionio/api/Watch.py @@ -61,8 +61,17 @@ class Watch(Resource): @validate_openapi_request('getWatch') def get(self, uuid): """Get information about a single watch, recheck, pause, or mute.""" + import time from copy import deepcopy - watch = deepcopy(self.datastore.data['watching'].get(uuid)) + watch = None + for _ in range(20): + try: + watch = deepcopy(self.datastore.data['watching'].get(uuid)) + break + except RuntimeError: + # Incase dict changed, try again + time.sleep(0.01) + if not watch: abort(404, message='No watch exists with the UUID of {}'.format(uuid))