[Twisted-Python] adapi.Connection._runQuery always does rollback()

Eric C. Newton ecn at metaslash.com
Sat Apr 26 09:55:46 EDT 2003


RedHat 9.0 on intel
Twisted 1.0.4

In twisted.enterprise.adbapi we find this method of ConnectionPool:

    def _runQuery(self, args, kw):
        conn = self.connect()
        curs = conn.cursor()
        try:
            apply(curs.execute, args, kw)
            result = curs.fetchall()
            curs.close()
        finally:
            conn.rollback()
        return result

I do not understand the logic of always running a rollback even if the
query is successful.  I would, instead, expect this:

    def _runQuery(self, args, kw):
        conn = self.connect()
        curs = conn.cursor()
        try:
            apply(curs.execute, args, kw)
            result = curs.fetchall()
            curs.close()
        except:
            conn.rollback()
	    raise
        return result

And, indeed, this is _exactly_ what we see in adbapi._runOperation,
which is the method following _runQuery.

-Eric

PS. This buglet brought to you by MySQL which does not support rollback(), 
    and tells you with an exception.




More information about the Twisted-Python mailing list