[Zope-dev] zope.sqlalchemy: Decoupling Zope3 and SQLAlchemy commit - how? Should I?

Brian Sutherland brian at vanguardistas.net
Mon Nov 3 08:21:49 EST 2008


On Sun, Nov 02, 2008 at 09:37:56PM +0100, Hermann Himmelbauer wrote:
> Hi,
> In one of my Zope3 projects, I use lovely.remotetask to run specific tasks in 
> background. These tasks do lengthy database operations via zope.sqlalchemy. 
> Currently, lovely.remotetask seems to do a Zope3 commit() at the end of the 
> task, which also does the SQLAlchemy commit.
> 
> However, some tasks consist of a loop over self-contained operations, 
> therefore it would be handy to commit after each such operation. This way, if 
> one of the operations fail (e.g. due to some database error, such as locking, 
> refrential integrity violation etc.), not the whole task is rolled back but 
> only one operation. Moreover, the probability of database locks is reduced.

I've never used lovely.remotetask, but I would suggest trying:

    * Have your "loop over self-contained operations" create more tasks.
    * Move the loop to the application and create many tasks, one for
      each operation.

-- 
Brian Sutherland


More information about the Zope-Dev mailing list