diff options
author | Wolfgang Müller | 2021-05-04 21:09:38 +0200 |
---|---|---|
committer | Wolfgang Müller | 2021-05-04 21:09:38 +0200 |
commit | f67f0f93e1c90eb778a51016c9777c9f7dae7839 (patch) | |
tree | 93d5cabfa305204b7219e8c42dc6ccbe3a462db5 | |
parent | 4cc2af4b8b81b8fb403a85b0e85bf585a4523b36 (diff) | |
download | quarg-f67f0f93e1c90eb778a51016c9777c9f7dae7839.tar.gz |
main: Handle BrokenPipeError cleanly
Whilst not recommended, quarg may happen to be used in conjunction with
head(1), tail(1), or any other program that will send SIGPIPE. This
commit makes sure that we close the database connection properly if we
receive that signal.
-rw-r--r-- | quarg/main.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/quarg/main.py b/quarg/main.py index 29138e3..5e0aaf8 100644 --- a/quarg/main.py +++ b/quarg/main.py @@ -144,7 +144,7 @@ def main(): print(formatter.format_from(row)) except exc.SQLAlchemyError as err: errx(err) - except KeyboardInterrupt: + except (KeyboardInterrupt, BrokenPipeError): session.rollback() session.close() sys.exit(1) |