Cleanup Session after each request.
It's good practice to cleanup the SQL session after each request so that the next request gets a fresh one. It's an application decision whether one wants a just-in-case ROLLBACK or COMMIT. There are two ideas behind it, really. I have decided for ROLLBACK. The idea is "if you forget to commit your changes yourself, there's something broken. Maybe you got an exception?".
This commit is contained in:
@@ -36,6 +36,7 @@ class DatabaseMaster(object):
|
||||
Session.flush()
|
||||
|
||||
def reset_after_request(self):
|
||||
Session.rollback()
|
||||
Session.remove()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user