diff --git a/.bin/Scripts/functions/hw_diags.py b/.bin/Scripts/functions/hw_diags.py index 7682f5cc..d11a694f 100644 --- a/.bin/Scripts/functions/hw_diags.py +++ b/.bin/Scripts/functions/hw_diags.py @@ -588,6 +588,10 @@ class State(): if not skip_disk: self.disks.append(disk_obj) + # Start tmux thread + self.tmux_layout = TMUX_LAYOUT.copy() + start_thread(fix_tmux_panes_loop, args=[self]) + class TestObj(): """Object to track test data.""" @@ -664,9 +668,6 @@ def fix_tmux_panes_loop(state): try: fix_tmux_panes(state) sleep(1) - except AttributeError: - # tmux_layout attribute has been deleted, exit function - return except RuntimeError: # Assuming layout definitions changes mid-run, ignoring pass @@ -676,6 +677,10 @@ def fix_tmux_panes(state): """Fix pane sizes if the window has been resized.""" needs_fixed = False + # Bail? + if not state.panes: + return + # Check layout for k, v in state.tmux_layout.items(): if not v.get('Check'): @@ -1013,7 +1018,6 @@ def run_hw_tests(state): # Build Panes update_progress_pane(state) build_outer_panes(state) - start_tmux_repair_thread(state) # Show selected tests and create TestObj()s print_info('Selected Tests:') @@ -1075,13 +1079,13 @@ def run_hw_tests(state): state.ost.post_device_results(state.cpu, state.ticket_id) except GenericAbort: # Cleanup - stop_tmux_repair_thread(state) tmux_kill_pane(*state.panes.values()) + state.panes.clear() + state.tmux_layout.pop('Current', None) # Rebuild panes update_progress_pane(state) build_outer_panes(state) - start_tmux_repair_thread(state) # Mark unfinished tests as aborted for k, v in state.tests.items(): @@ -1138,6 +1142,7 @@ def run_hw_tests(state): state.ost.disconnect(full=True) stop_tmux_repair_thread(state) tmux_kill_pane(*state.panes.values()) + state.panes.clear() def run_io_benchmark(state, test): @@ -1681,19 +1686,6 @@ def show_results(state): update_progress_pane(state) -def start_tmux_repair_thread(state): - """Fix tmux panes as long as state.tmux_layout attribute exists.""" - state.tmux_layout = TMUX_LAYOUT.copy() - start_thread(fix_tmux_panes_loop, args=[state]) - - -def stop_tmux_repair_thread(state): - """Stop previous thread by causing an AttributeError in the thread.""" - if hasattr(state, 'tmux_layout'): - del state.tmux_layout - sleep(1) - - def update_main_options(state, selection, main_options): """Update menu and state based on selection.""" index = int(selection) - 1