sasync.database
module documentation
Part of sasync
Asynchronous database transactions via SQLAlchemy
and
Twisted
. You will surely have a subclass of AccessBroker
.
Function | transaction | Everything making up a transaction, and everything run in the thread, is
contained within this little function, including of course a call to
func . |
Function | nextFromRP | Transaction magic. |
Function | isNested | Transaction magic. |
Function | transact | Transaction decorator. |
Function | wait | Decorator to wait for any Deferred that has been returned
by a method of AccessBroker to
fire before proceeding with the shutdown method of AccessBroker . |
Class | AccessBroker | I manage asynchronous access to a database. |
Everything making up a transaction, and everything run in the thread, is
contained within this little function, including of course a call to
func
.
Transaction decorator.
Use this function as a decorator to wrap the supplied method f of
AccessBroker
in a transaction that runs f(*args, **kw)
in its own
transaction.
Immediately returns a Deferred
that will eventually have
its callback called with the result of the transaction. Inspired by and
largely copied from Valentino Volonghi's makeTransactWith
code.
You can add the following keyword options to your function call:
Parameters | niceness | Scheduling niceness, an integer between -20 and 20, with lower numbers
having higher scheduling priority as in UNIX nice and
renice . |
doNext | Set True to assign highest possible priority, even higher than
with niceness = -20. | |
doLast | Set True to assign lower possible priority, even lower than
with niceness = 20. | |
consumer | Set this to a consumer object (must implement the
twisted.interfaces.IConsumer interface) and the
SA.ResultProxy will write its rows to it in Twisted fashion.
The returned Deferred will fire when all rows have been
written. | |
raw | Set True to have the transaction result returned in its
original form even if it's a RowProxy or other iterator. |
Decorator to wait for any Deferred
that has been returned
by a method of AccessBroker
to
fire before proceeding with the shutdown method of AccessBroker
.
Sometimes calls to methods you define to an AccessBroker
subclass will still be pending when you call for a shutdown. If those
pending calls rely on the task queue to finish, you can wait for them
before the AccessBroker.shutdown
method proceeds by decorating the method with this function.