[Checkins] SVN: zope.sqlalchemy/trunk/src/zope/sqlalchemy/datamanager.py Move session.close into finish after we clear the state.
Brian Sutherland
jinty at web.de
Thu Sep 18 03:56:00 EDT 2008
Log message for revision 91231:
Move session.close into finish after we clear the state.
Changed:
U zope.sqlalchemy/trunk/src/zope/sqlalchemy/datamanager.py
-=-
Modified: zope.sqlalchemy/trunk/src/zope/sqlalchemy/datamanager.py
===================================================================
--- zope.sqlalchemy/trunk/src/zope/sqlalchemy/datamanager.py 2008-09-17 21:54:35 UTC (rev 91230)
+++ zope.sqlalchemy/trunk/src/zope/sqlalchemy/datamanager.py 2008-09-18 07:55:58 UTC (rev 91231)
@@ -50,14 +50,17 @@
self.state = 'init'
def _finish(self, final_state):
- assert self.session is not None
+ assert self.tx is not None
+ session = self.session
del _SESSION_STATE[id(self.session)]
self.tx = self.session = None
self.state = final_state
+ # closing the session is the last thing we do. If it fails the
+ # transactions don't get wedged and the error propagates
+ session.close()
def abort(self, trans):
if self.tx is not None: # there may have been no work to do
- self.session.close()
self._finish('aborted')
def tpc_begin(self, trans):
@@ -66,14 +69,12 @@
def commit(self, trans):
status = _SESSION_STATE[id(self.session)]
if status is not STATUS_INVALIDATED:
- self.session.close()
self._finish('no work')
def tpc_vote(self, trans):
# for a one phase data manager commit last in tpc_vote
if self.tx is not None: # there may have been no work to do
self.tx.commit()
- self.session.close()
self._finish('committed')
def tpc_finish(self, trans):
@@ -114,13 +115,11 @@
def tpc_finish(self, trans):
if self.tx is not None:
self.tx.commit()
- self.session.close()
self._finish('committed')
def tpc_abort(self, trans):
if self.tx is not None: # we may not have voted, and been aborted already
self.tx.rollback()
- self.session.close()
self._finish('aborted commit')
def sortKey(self):
More information about the Checkins
mailing list