From 235535c32748244de08a760a18a700bcebe45eed Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Sat, 17 Dec 2022 15:40:57 +0100 Subject: [PATCH] Fetching - Check the most overdue watch first (#1242) --- changedetectionio/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/changedetectionio/__init__.py b/changedetectionio/__init__.py index c50c62da..36e80f56 100644 --- a/changedetectionio/__init__.py +++ b/changedetectionio/__init__.py @@ -1449,7 +1449,11 @@ def ticker_thread_check_time_launch_checks(): watch_uuid_list = [] while True: try: - watch_uuid_list = datastore.data['watching'].keys() + # Get a list of watches sorted by last_checked, [1] because it gets passed a tuple + # This is so we examine the most over-due first + for k in sorted(datastore.data['watching'].items(), key=lambda item: item[1].get('last_checked',0)): + watch_uuid_list.append(k[0]) + except RuntimeError as e: # RuntimeError: dictionary changed size during iteration time.sleep(0.1)