From 4a0437b5e20cad126ac6d344cad1f6bf1ca094b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alban=20F=C3=A9ron?= Date: Sun, 14 Apr 2024 15:59:51 +0200 Subject: [PATCH] Fix(?) watcher queue sometimes not stopping when asked Ref #263 --- supysonic/watcher.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/supysonic/watcher.py b/supysonic/watcher.py index 76fa6d5..a99ed9f 100644 --- a/supysonic/watcher.py +++ b/supysonic/watcher.py @@ -141,7 +141,10 @@ class ScannerProcessingQueue(Thread): time.sleep(0.1) with self.__cond: - self.__cond.wait() + # Flag might have flipped during sleep. Check it again before waiting + # See issue #263 + if self.__running: + self.__cond.wait() if not self.__queue: continue @@ -195,8 +198,8 @@ class ScannerProcessingQueue(Thread): scanner.add_cover(item.path) def stop(self): - self.__running = False with self.__cond: + self.__running = False self.__cond.notify() def put(self, path, operation, **kwargs):