From 72aa95b191fa72055a57c57cc79a68c3a6ebec4b Mon Sep 17 00:00:00 2001 From: Alessandro Astone Date: Fri, 27 Jan 2023 17:20:38 +0100 Subject: [PATCH] interfaces: Remove presence handler after use --- tools/interfaces/IPlatform.py | 3 ++- tools/interfaces/IStatusBarService.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/interfaces/IPlatform.py b/tools/interfaces/IPlatform.py index 12d1e1d..67f8a3e 100644 --- a/tools/interfaces/IPlatform.py +++ b/tools/interfaces/IPlatform.py @@ -326,10 +326,11 @@ def get_service(args): # Like ServiceManager.wait() but can be interrupted def wait_for_manager(sm): mainloop = GLib.MainLoop() - sm.add_presence_handler(lambda: mainloop.quit() if sm.is_present() else None) + hndl = sm.add_presence_handler(lambda: mainloop.quit() if sm.is_present() else None) GLib.timeout_add_seconds(60, lambda: mainloop.quit()) GLib.unix_signal_add(GLib.PRIORITY_HIGH, signal.SIGINT, lambda _: mainloop.quit(), None) mainloop.run() + sm.remove_handler(hndl) if not sm.is_present(): return False return True diff --git a/tools/interfaces/IStatusBarService.py b/tools/interfaces/IStatusBarService.py index af572dd..d4dad60 100644 --- a/tools/interfaces/IStatusBarService.py +++ b/tools/interfaces/IStatusBarService.py @@ -73,10 +73,11 @@ def get_service(args): # Like ServiceManager.wait() but can be interrupted def wait_for_manager(sm): mainloop = GLib.MainLoop() - sm.add_presence_handler(lambda: mainloop.quit() if sm.is_present() else None) + hndl = sm.add_presence_handler(lambda: mainloop.quit() if sm.is_present() else None) GLib.timeout_add_seconds(60, lambda: mainloop.quit()) GLib.unix_signal_add(GLib.PRIORITY_HIGH, signal.SIGINT, lambda _: mainloop.quit(), None) mainloop.run() + sm.remove_handler(hndl) if not sm.is_present(): return False return True -- 2.47.3