Skip to content

Commit 10ba4bc

Browse files
authored
Merge pull request #1239 from dbcli/RW/more-informative-query-cancel-keyboard-interrupt
More information and care on `KeyboardInterrupt`
2 parents b44956f + aa46615 commit 10ba4bc

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Features
55
--------
66

77
* Support SSL query parameters on DSNs.
8+
* More information and care on KeyboardInterrupt.
89

910
Internal
1011
--------

mycli/main.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -774,11 +774,19 @@ def one_iteration(text=None):
774774
status_str = str(status).lower()
775775
if status_str.find("ok") > -1:
776776
logger.debug("cancelled query, connection id: %r, sql: %r", connection_id_to_kill, text)
777-
self.echo("cancelled query", err=True, fg="red")
777+
self.echo(f"Cancelled query id: {connection_id_to_kill}", err=True, fg="blue")
778+
else:
779+
logger.debug(
780+
"Failed to confirm query cancellation, connection id: %r, sql: %r",
781+
connection_id_to_kill,
782+
text,
783+
)
784+
self.echo(f"Failed to confirm query cancellation, id: {connection_id_to_kill}", err=True, fg="red")
778785
except Exception as e:
779786
self.echo("Encountered error while cancelling query: {}".format(e), err=True, fg="red")
780787
else:
781788
logger.debug("Did not get a connection id, skip cancelling query")
789+
self.echo("Did not get a connection id, skip cancelling query", err=True, fg="red")
782790
except NotImplementedError:
783791
self.echo("Not Yet Implemented.", fg="yellow")
784792
except OperationalError as e:

0 commit comments

Comments
 (0)