diff --git a/lib/daemon.py b/lib/daemon.py index f9a0fd637..4b67a7c69 100644 --- a/lib/daemon.py +++ b/lib/daemon.py @@ -220,6 +220,7 @@ class Daemon(DaemonThread): self.print_error("shutting down network") self.network.stop() self.network.join() + self.on_stop() def stop(self): self.print_error("stopping, removing lockfile") diff --git a/lib/network.py b/lib/network.py index cdc857869..36c7bd51b 100644 --- a/lib/network.py +++ b/lib/network.py @@ -814,7 +814,7 @@ class Network(util.DaemonThread): self.process_pending_sends() self.stop_network() - self.print_error("stopped") + self.on_stop() def on_header(self, i, header): height = header.get('block_height') diff --git a/lib/plugins.py b/lib/plugins.py index 608b3ca95..d1d1f797a 100644 --- a/lib/plugins.py +++ b/lib/plugins.py @@ -169,7 +169,7 @@ class Plugins(DaemonThread): while self.is_running(): time.sleep(0.1) self.run_jobs() - self.print_error("stopped") + self.on_stop() hook_names = set() diff --git a/lib/util.py b/lib/util.py index 1c2602d88..508188ee5 100644 --- a/lib/util.py +++ b/lib/util.py @@ -149,6 +149,12 @@ class DaemonThread(threading.Thread, PrintError): with self.running_lock: self.running = False + def on_stop(self): + if 'ANDROID_DATA' in os.environ: + import jnius + jnius.detach() + self.print_error("jnius detach") + self.print_error("stopped") is_verbose = False