summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Schubert <contact@benschubert.me>2019-11-08 11:41:53 +0000
committerJürg Billeter <j@bitron.ch>2020-01-16 07:34:01 +0000
commitca3096b8f2912215bfbb631fe8fbb42621e10a6f (patch)
tree2f74c3c5488eaa618edc4ac01bd4e1e38a6c90e9
parent528b33bddf383b2f46457a12c88b07cba47ff8d6 (diff)
downloadbuildstream-bschubert/backport-1690.tar.gz
app.py: Also catch SystemError with click.Abortbschubert/backport-1690
This is to catch an error when sometimes the readline buffer of stdin gets corrupted during the second CTRL-C we send, and leads to having BuildStream hand and throw a SystemError. Catching the SystemError and treating as a click.Abort doesn't seem to have adverse effects.
-rw-r--r--buildstream/_frontend/app.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/buildstream/_frontend/app.py b/buildstream/_frontend/app.py
index cb9870c4d..50e1e79b0 100644
--- a/buildstream/_frontend/app.py
+++ b/buildstream/_frontend/app.py
@@ -504,7 +504,10 @@ class App():
choice = click.prompt("Choice:",
value_proc=_prefix_choice_value_proc(['continue', 'quit', 'terminate']),
default='continue', err=True)
- except click.Abort:
+ except (click.Abort, SystemError):
+ # In some cases, the readline buffer underlying the prompt gets corrupted on the second CTRL+C
+ # This throws a SystemError, which doesn't seem to be problematic for the rest of the program
+
# Ensure a newline after automatically printed '^C'
click.echo("", err=True)
choice = 'terminate'
@@ -599,7 +602,10 @@ class App():
try:
choice = click.prompt("Choice:", default='continue', err=True,
value_proc=_prefix_choice_value_proc(choices))
- except click.Abort:
+ except (click.Abort, SystemError):
+ # In some cases, the readline buffer underlying the prompt gets corrupted on the second CTRL+C
+ # This throws a SystemError, which doesn't seem to be problematic for the rest of the program
+
# Ensure a newline after automatically printed '^C'
click.echo("", err=True)
choice = 'terminate'