On May 13, 2011, at 4:47 AM, Luper Rouch wrote:
>
> Louie is not asynchronous, it's just a simple dispatcher that calls
> functions connected to emitted signals immediately. We use it to
> handle database events cleanly, without tightly coupling different
> parts of the system (e.g. tables that are monitored by the versioning
> system don't have to know anything about it, it's the versioning
> system that listens to changes on versioned tables).
>
> I have a working implementation now with the failure recovery tests
> passing [1], thanks a lot Michael for your help.
>
> [1] http://paste.pocoo.org/show/387971/
I would note that the begin(subtransactions=True)/commit()/rollback() set
inside handle_exceptions() doesn't have any purpose unless the Session is being
used both in autocommit=True mode as well as autocommit=False at different
times. If you're in autocommit=False, there is always a transaction in
progress when using the Session.
A more succinct decorator that should have the same effect, that is call
rollback() immediately, would be:
def handle_exceptions(func):
def wrapper(*args, **kwargs):
try:
return func(*args, **kwargs)
except:
session = args[1]
session.rollback()
raise
return wrapper
still strange that you'd want to swallow the need for rollback() within the two
extension methods, but not within the flush() overall. Just continues to
raise questions what the application outside of these extensions looks like :)
(but we can leave it here, just adding a note for future viewers of this thread)
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en.