Table of Contents

Class: autocommitted ./src/peak/storage/autocommit.py

meth = autocommited(meth) - Wrap a method with autocommit support

AutoCommitter classes should wrap any methods which want to be atomic operations in an autocommitted() advice. For example:

        from peak.storage.autocommit import *

        class QueuedMessageSender(AutoCommitter):

            def send(self,message):
                # ...

            send = autocommitted(send)

When a QueuedMessageSender object's send() method is called, it will be wrapped in a transaction as long as the object was created with a true setting for its autocommit parameter. If an error is raised from send(), the transaction will be aborted, otherwise it will be committed.

If a wrapped method is called from inside another autocommitted() method of the same object, or if the object doesn't have autocommit set to a true value, no special transaction handling occurs.

Note that errors raised during the wrapping transaction's commit or abort method may leave the object's transaction service stuck in a failure mode, where it cannot be committed, only aborted. This can be fixed by calling the theBrokenObject.txnSvc.abort() until it no longer raises an exception. Or, it may be more worthwhile to set up a custom error handler on the transaction service instance used for autocommit transactions. Once we have enough experience with this issue to know what's most useful, we may add such an error handler to the AutoCommitter default txnSvc setup code.

Also note that wrapped methods should always use self.joinedTxn to ensure they have joined a transaction; this wrapper doesn't do it for you. (It can't, since it would then fail to work correctly when autocommit is turned off.)

Base Classes   
advice
Methods   
__call__
  __call__ 
__call__ (
        __advice,
        self,
        *__args,
        *__kw,
        )


Table of Contents

This document was automatically generated on Mon May 13 01:11:05 2024 by HappyDoc version 2.1