[Twisted-Python] adbapi and long-running transactions

Wolfgang Powisch (privat) powo at powo.priv.at
Fri Apr 10 12:16:59 EDT 2009


I'm using twisted.enterprise.adbapi for non-blocking database interaction with
a postgres database.

Currently I'm only using runQuery or runOperation for running single queries or
some own little helper methods "runQueries" or "runOperations" for running
multiple queries within one Transaction (using runInteraction).

What I need now is to start a Transaction and access this Transaction from
multiple callbacks within my application-code in the main-thread. In the last
callback (and/or errback) I will then either commit or rollback the transaction.

Any ideas how to acomplish that, didn't find a working solution yet.

The two options I tested are:

1.) running my code within the adbapi thread using runInteraction:
    -> this is really not what I want and will screw up my code

2.) create a transaction and pass it as an argument to a function called with
    -> this doesn't work, because I seem to end up in the wrong thread and
       another (or no) transaction.

thx in advance for your help

regards, Wolfgang

More information about the Twisted-Python mailing list