[Twisted-Python] PATCH: runQuery

Clark C. Evans cce at clarkevans.com
Thu Mar 6 16:01:43 EST 2003


Federico,

Glyph is giving me CVS access soon; when he does, I'll
patch and test (beacuse I need to merge it in with my
'fetchmany' code).

Thanks for the patch,

Clark

On Thu, Mar 06, 2003 at 03:04:44PM +0100, Federico Di Gregorio wrote:
| while patching runQuery to solve my postgresql/psycopg problems i
| discovered a much problematic problem.
| 
| essentially if a query run through runQuery raise an exception, the
| exception is propagated but rollback() is never called on the
| connection. this leaves the connection in a "dirty" state and the
| effects on the next query are database dependent (postgresql, for
| example,  will simply discard all following queries until next
| rollback()).
| 
| a patch follows:
| 
| --- adbapi.py-old       2003-03-06 12:48:02.000000000 +0100
| +++ adbapi.py   2003-03-06 13:02:33.000000000 +0100
| @@ -94,9 +94,12 @@
|      def _runQuery(self, args, kw):
|          conn = self.connect()
|          curs = conn.cursor()
| -        apply(curs.execute, args, kw)
| -        result = curs.fetchall()
| -        curs.close()
| +       try:
| +           apply(curs.execute, args, kw)
| +           result = curs.fetchall()
| +           curs.close()
| +       finally:
| +           conn.rollback()
|          return result
|   
|      def _runOperation(self, args, kw):
| 
| -- 
| Federico Di Gregorio
| Debian GNU/Linux Developer                                fog at debian.org
| INIT.D Developer                                           fog at initd.org
|                              Best friends are often failed lovers. -- Me






More information about the Twisted-Python mailing list