From 44672be5279675fd2d60e19ed9c4e607bd03bd98 Mon Sep 17 00:00:00 2001 From: Tomaz Muraus Date: Fri, 24 Jan 2020 19:53:02 +0100 Subject: [PATCH 1/2] Fix check ffmpeg thread and init casts threads blocking the main GUI loop. Previously, if you pressed CTRL+C or exit before those threads finished (aka before all the chromecasts were discovered on the local network) the application would block and only exit when the chromecast discovery finished. This pull request fixes that by making those two threads daemon threads. This way they don't block the main GUI thread, but everything still works as it should. --- gnomecast.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gnomecast.py b/gnomecast.py index 5bd1ca8..aa2a09c 100644 --- a/gnomecast.py +++ b/gnomecast.py @@ -401,7 +401,7 @@ def __init__(self): def run(self, fn=None, device=None, subtitles=None): self.build_gui() self.init_casts(device=device) - threading.Thread(target=self.check_ffmpeg).start() + threading.Thread(target=self.check_ffmpeg, daemon=True).start() t = threading.Thread(target=self.start_server) t.daemon = True t.start() @@ -522,7 +522,8 @@ def init_casts(self, widget=None, device=None): self.cast_store.clear() self.cast_store.append([None, "Searching local network - please wait..."]) self.cast_combo.set_active(0) - threading.Thread(target=self.load_casts, kwargs={'device':device}).start() + t = threading.Thread(target=self.load_casts, daemon=True, kwargs={'device':device}).start() + return t def inhibit_screensaver(self): if not self.saver_interface or self.inhibit_screensaver_cookie: return From ec30ace701cb207c38e931b079c75ee9ffc627e7 Mon Sep 17 00:00:00 2001 From: Tomaz Muraus Date: Fri, 24 Jan 2020 20:00:08 +0100 Subject: [PATCH 2/2] No need to return the thread since we went with a very simple daemon thread approach to solve the blocked UI / main thread issue. --- gnomecast.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gnomecast.py b/gnomecast.py index aa2a09c..2aa585c 100644 --- a/gnomecast.py +++ b/gnomecast.py @@ -522,8 +522,7 @@ def init_casts(self, widget=None, device=None): self.cast_store.clear() self.cast_store.append([None, "Searching local network - please wait..."]) self.cast_combo.set_active(0) - t = threading.Thread(target=self.load_casts, daemon=True, kwargs={'device':device}).start() - return t + threading.Thread(target=self.load_casts, daemon=True, kwargs={'device':device}).start() def inhibit_screensaver(self): if not self.saver_interface or self.inhibit_screensaver_cookie: return