Two phase support for sessions / threadedlocal engine
Issue #936
resolved
The threadlocal engine uses sessions for it's transaction support, and these do not support two phase commit.
Comments (4)
-
repo owner -
Account Deleted This patch fixes it for me. It was mostly there already. Laurence (l@lrowe.co.uk)
Index: lib/sqlalchemy/engine/threadlocal.py =================================================================== --- lib/sqlalchemy/engine/threadlocal.py (revision 4192) +++ lib/sqlalchemy/engine/threadlocal.py (working copy) @@ -38,17 +38,9 @@ def prepare(self): if self.__tcount == 1: - try: - self.__trans._trans.prepare() - finally: - self.reset() + self.__trans._trans.prepare() def begin_twophase(self, xid=None): - raise NotImplementedError( - "Two phase transactions not yet implemented for 'threadlocal' " - "strategy") - - def _dont_begin_twophase(self, xid=None): if self.__tcount == 0: self.__transaction = self.get_connection() self.__trans = self.__transaction._begin_twophase(xid=xid)
-
repo owner - changed status to resolved
OK, I implemented that patch plus methods directly on
TLEngine
itself (since the API is typically from the engine) as well as a rudimentary test in 82edfd0e915717dbc93d53247e5f2515ac5dd474. What's not tested there is more complex interactions between standalone connections, transactions, andTLEngine
but the idea for basic usage should be good.thanks for the patch !
-
repo owner - removed milestone
Removing milestone: 0.4.xx (automated comment)
- Log in to comment
hmm maybe ants has some time for this one, or I can get to it, it should be fairly straightforward. Do you have an immediate need for this ?