Commit 2387761f authored by Martin Mareš's avatar Martin Mareš
Browse files

Hook: Reset DB transaction at the end of each request

parent f4e51085
......@@ -38,6 +38,15 @@ def db_query(query, args=()):
db_connect()
db.execute(query, args)
def db_reset():
# At the end of every request, we have to close the implicitly opened
# transaction. Otherwise we end up with serving stale data.
if db_connection is not None:
try:
db_connection.rollback()
except:
pass
### Utilities ###
def parse_time(iso_time):
......@@ -279,3 +288,5 @@ def application(env, start_response):
except Exception as exc:
app.log(traceback.print_exception(etype=None, value=exc, tb=exc.__traceback__))
return app.http_error(500, "Internal server error")
finally:
db_reset()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment