diff options
author | Elrond <elrond+mediagoblin.org@samba-tng.org> | 2012-04-07 23:21:59 +0200 |
---|---|---|
committer | Elrond <elrond+mediagoblin.org@samba-tng.org> | 2012-04-07 23:21:59 +0200 |
commit | e824570a23b3939803cee8a3fd6df0fd5e754de0 (patch) | |
tree | 252d63eb8f9793e5c7a80be65f17777f8d48d480 /mediagoblin/db/sql/open.py | |
parent | abe74178270cf84c26ebda5e2209902b9f963fd5 (diff) | |
download | mediagoblin-e824570a23b3939803cee8a3fd6df0fd5e754de0.tar.lz mediagoblin-e824570a23b3939803cee8a3fd6df0fd5e754de0.tar.xz mediagoblin-e824570a23b3939803cee8a3fd6df0fd5e754de0.zip |
Cleanup sql session after request. ALWAYS!
The cleanup could be missed if the request handling code in
app.py:__call__ exits early (due to exception, or due to
one of those early "return"s).
So to make sure the sql session is cleaned up for real,
wrap the whole thing in a try: finally:.
Also wrote a short tool to test if the session is actually
empty. The tool is currently disabled, but ready to be
used.
Diffstat (limited to 'mediagoblin/db/sql/open.py')
-rw-r--r-- | mediagoblin/db/sql/open.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/mediagoblin/db/sql/open.py b/mediagoblin/db/sql/open.py index edbf0785..ce5f0604 100644 --- a/mediagoblin/db/sql/open.py +++ b/mediagoblin/db/sql/open.py @@ -37,6 +37,12 @@ class DatabaseMaster(object): Session.add(obj) Session.flush() + def check_session_clean(self): + for dummy in Session(): + _log.warn("STRANGE: There are elements in the sql session. " + "Please report this and help us track this down.") + break + def reset_after_request(self): Session.rollback() Session.remove() |