diff options
author | Benjamin Schubert <contact@benschubert.me> | 2019-11-08 11:41:53 +0000 |
---|---|---|
committer | Benjamin Schubert <contact@benschubert.me> | 2019-11-08 11:41:53 +0000 |
commit | 5e0d8d5abe7b525ad28875db0146231be5e39453 (patch) | |
tree | 586cce42d79339c1a49c666be5aa8603b524dcf3 /src/buildstream/_frontend | |
parent | a283f02ce9f5d72f03c783d516d69d8f57069ef4 (diff) | |
download | buildstream-5e0d8d5abe7b525ad28875db0146231be5e39453.tar.gz |
app.py: Also catch SystemError with click.Abort
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.
Diffstat (limited to 'src/buildstream/_frontend')
-rw-r--r-- | src/buildstream/_frontend/app.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/buildstream/_frontend/app.py b/src/buildstream/_frontend/app.py index 45160afbc..596ef168a 100644 --- a/src/buildstream/_frontend/app.py +++ b/src/buildstream/_frontend/app.py @@ -532,7 +532,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' @@ -630,7 +633,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' |