From 23e87db8fa2f8790e543bf3e32623540246446f5 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Wed, 13 May 2015 03:02:35 +0000 Subject: [PATCH] * introduce signal_cleanup so we can run cleanup things from the signal handler (non UI things) * move stop_all_sound early, since it is asynchronous / kills processes git-svn-id: https://xpra.org/svn/Xpra/trunk@9337 3bb7dfac-3a0b-4e04-842a-767bc560f471 --- src/xpra/client/client_base.py | 6 ++++++ src/xpra/client/ui_client_base.py | 11 ++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/xpra/client/client_base.py b/src/xpra/client/client_base.py index 4e07dd1605..88a4d614b5 100644 --- a/src/xpra/client/client_base.py +++ b/src/xpra/client/client_base.py @@ -165,6 +165,7 @@ def app_signal(signum, frame): sys.stderr.flush() signal.signal(signal.SIGINT, deadly_signal) signal.signal(signal.SIGTERM, deadly_signal) + self.signal_cleanup() self.timeout_add(0, self.disconnect_and_quit, 128 + signum, "exit on signal %s" % SIGNAMES.get(signum, signum)) signal.signal(signal.SIGINT, app_signal) signal.signal(signal.SIGTERM, app_signal) @@ -181,6 +182,11 @@ def signal_disconnect_and_quit(self, exit_code, reason): self.disconnect_and_quit(exit_code, reason) self.quit(exit_code) + def signal_cleanup(self): + #placeholder for stuff that can be cleaned up from the signal handler + #(non UI thread stuff) + pass + def disconnect_and_quit(self, exit_code, reason): #try to tell the server we're going, then quit log("disconnect_and_quit(%s, %s)", exit_code, reason) diff --git a/src/xpra/client/ui_client_base.py b/src/xpra/client/ui_client_base.py index 8ddb65fc46..3f7ee3213f 100644 --- a/src/xpra/client/ui_client_base.py +++ b/src/xpra/client/ui_client_base.py @@ -368,6 +368,7 @@ def quit(self, exit_code=0): def cleanup(self): log("UIXpraClient.cleanup()") XpraClientBase.cleanup(self) + self.stop_all_sound() for x in (self.keyboard_helper, self.clipboard_helper, self.tray, self.notifier, self.menu_helper, self.client_extras, getVideoHelper()): if x is None: continue @@ -380,12 +381,20 @@ def cleanup(self): #(cleaner and needed when we run embedded in the client launcher) self.destroy_all_windows() self.clean_mmap() + reaper_cleanup() + log("UIXpraClient.cleanup() done") + + def stop_all_sound(self): if self.sound_source: self.stop_sending_sound() if self.sound_sink: self.stop_receiving_sound() + + def signal_cleanup(self): + XpraClientBase.signal_cleanup(self) + self.stop_all_sound() reaper_cleanup() - log("UIXpraClient.cleanup() done") + def destroy_all_windows(self): for wid, window in self._id_to_window.items():