aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/wqflask/database.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/wqflask/wqflask/database.py b/wqflask/wqflask/database.py
index 84c494c5..7e03a000 100644
--- a/wqflask/wqflask/database.py
+++ b/wqflask/wqflask/database.py
@@ -68,8 +68,10 @@ def xapian_database():
"""Open xapian database read-only."""
# pylint: disable-next=invalid-name
db = xapian.Database(get_setting("XAPIAN_DB_PATH"))
- yield db
- db.close()
+ try:
+ yield db
+ finally:
+ db.close()
@contextlib.contextmanager
@@ -77,5 +79,7 @@ def xapian_writable_database():
"""Open xapian database for writing."""
# pylint: disable-next=invalid-name
db = xapian.WritableDatabase(get_setting("XAPIAN_DB_PATH"))
- yield db
- db.close()
+ try:
+ yield db
+ finally:
+ db.close()