[nyx/master] Replace stop_controller() with halt() method
commit 9555a8a14a3940df452d5640d82f6921e17066e5 Author: Damian Johnson <atagar@torproject.org> Date: Thu Feb 11 20:37:10 2016 -0800 Replace stop_controller() with halt() method Feels a little better as a Controller method. --- nyx/controller.py | 36 ++++++++++++++++-------------------- nyx/starter.py | 9 +++++---- 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/nyx/controller.py b/nyx/controller.py index e35c929..e143b49 100644 --- a/nyx/controller.py +++ b/nyx/controller.py @@ -56,26 +56,6 @@ def get_controller(): return NYX_CONTROLLER -def stop_controller(): - """ - Halts our Controller, providing back the thread doing so. - """ - - def halt_controller(): - control = get_controller() - - if control: - for panel_impl in control.get_daemon_panels(): - panel_impl.stop() - - for panel_impl in control.get_daemon_panels(): - panel_impl.join() - - halt_thread = threading.Thread(target = halt_controller) - halt_thread.start() - return halt_thread - - class LabelPanel(panel.Panel): """ Panel that just displays a single line of text. @@ -373,6 +353,22 @@ class Controller: def quit(self): self.quit_signal = True + def halt(self): + """ + Halts curses panels, providing back the thread doing so. + """ + + def halt_panels(): + for panel_impl in self.get_daemon_panels(): + panel_impl.stop() + + for panel_impl in self.get_daemon_panels(): + panel_impl.join() + + halt_thread = threading.Thread(target = halt_panels) + halt_thread.start() + return halt_thread + def start_nyx(stdscr): """ diff --git a/nyx/starter.py b/nyx/starter.py index 6084d04..326bd82 100644 --- a/nyx/starter.py +++ b/nyx/starter.py @@ -265,10 +265,11 @@ def _shutdown_daemons(controller): Stops and joins on worker threads. """ - halt_threads = [ - nyx.controller.stop_controller(), - nyx.util.tracker.stop_trackers(), - ] + halt_threads = [nyx.util.tracker.stop_trackers()] + controller = nyx.controller.get_controller() + + if controller: + halt_threads.append(controller.halt()) for thread in halt_threads: thread.join()
participants (1)
-
atagar@torproject.org