aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorWolfgang Müller2021-05-04 21:09:38 +0200
committerWolfgang Müller2021-05-04 21:09:38 +0200
commitf67f0f93e1c90eb778a51016c9777c9f7dae7839 (patch)
tree93d5cabfa305204b7219e8c42dc6ccbe3a462db5
parent4cc2af4b8b81b8fb403a85b0e85bf585a4523b36 (diff)
downloadquarg-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.
Diffstat (limited to '')
-rw-r--r--quarg/main.py2
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)