From 073e05a7fe915be3336f1f636803ae43584f4f62 Mon Sep 17 00:00:00 2001 From: Roland Walker Date: Wed, 7 Oct 2026 07:17:31 -0400 Subject: [PATCH] let slow query alert happen before paged output beep_after_seconds sets a threshold time for the user to receive an alarm on the completion of a slow query. The idea behind the feature is that the user may have tabbed away from mycli while waiting and would like an alert to tab back. But the implementation was sending the alarm _after_ the output, meaning that if the output was long enough to be paged, the beep would not be heard on query-completion, but rather on pager-exit, defeating the purpose. --- changelog.md | 5 +++++ mycli/main_modes/repl.py | 12 ++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/changelog.md b/changelog.md index 8db0c73b..25994b1c 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,11 @@ Upcoming (TBD) ============== +Bug Fixes +-------- +* Let the `beep_after_seconds` slow query alert happen before paged output. + + Internal -------- * `pyproject.toml` readability tweak. diff --git a/mycli/main_modes/repl.py b/mycli/main_modes/repl.py index d43868d4..ee8eab67 100644 --- a/mycli/main_modes/repl.py +++ b/mycli/main_modes/repl.py @@ -543,6 +543,9 @@ def _output_results( ) duration = time.time() - start + if mycli.beep_after_seconds > 0 and duration >= mycli.beep_after_seconds: + assert mycli.prompt_session is not None + mycli.prompt_session.output.bell() try: if result_count > 0: if runner: @@ -556,9 +559,6 @@ def _output_results( finally: if runner: runner.stop_rendering() - if mycli.beep_after_seconds > 0 and duration >= mycli.beep_after_seconds: - assert mycli.prompt_session is not None - mycli.prompt_session.output.bell() if special_commands.is_timing_enabled(): mycli.output_timing(f'Time: {duration:0.03f}s') except KeyboardInterrupt: @@ -648,6 +648,9 @@ def _single_paged_output_results( max_width=max_width, ) duration = time.time() - start + if mycli.beep_after_seconds > 0 and duration >= mycli.beep_after_seconds: + assert mycli.prompt_session is not None + mycli.prompt_session.output.bell() if result_count > 0: mycli.log_output('') @@ -662,9 +665,6 @@ def _single_paged_output_results( mycli.log_output(result.status_plain) yield f'{result.status_plain}\n' - if mycli.beep_after_seconds > 0 and duration >= mycli.beep_after_seconds: - assert mycli.prompt_session is not None - mycli.prompt_session.output.bell() if special_commands.is_timing_enabled(): timing = f'Time: {duration:0.03f}s' mycli.log_output(timing)