On May 12, 1:04 pm, Luper Rouch <luper.ro...@gmail.com> wrote: > On May 11, 5:00 pm, Luper Rouch <luper.ro...@gmail.com> wrote: > > > > > > > > > > > On May 11, 3:38 pm, Michael Bayer <mike...@zzzcomputing.com> wrote: > > > > On May 11, 2011, at 8:11 AM, Luper Rouch wrote: > > > > > I agree, when a timeout happens, we display an error message and tell > > > > the user its last operation failed. The point is not recovering from > > > > the failure automatically, but avoiding the "The transaction is > > > > inactive due to a rollback in a subtransaction. Issue rollback() to > > > > cancel the transaction" error, which happens on all subsequent queries. > > > > you need to call rollback() on the Session when an error occurs. This > > > because you're maintaining the transaction. > > > > Full info on why this is, as well as follow up questions, is at: > > > >http://www.sqlalchemy.org/trac/wiki/FAQ#Thetransactionisinactivedueto... > > > Yes I know, the problem is you can't do the rollback in the event > > handler (this leads to a "the transaction is closed" error), you have > > to put all the session.flush() calls that might trigger an event > > throwing an exception in a try/except and do the rollback. > > > I will implement my own events the way you describe below, by keeping > > track of items between before_flush() and after_flush_postexec() and > > triggering events at these moments, I think that will solve all my > > issues. > > I still have the exact same issue when using SessionExtension's > before_flush() and after_flush_postexec() methods, demonstrated here > :http://paste.pocoo.org/show/387444/ > > Line 87 raises the same "InvalidRequestError: The transaction is > inactive due to a rollback in a subtransaction. Issue rollback() to > cancel the transaction." error.
Someone on IRC suggested to do the rollback twice in handle_exceptions(). This seems to work and solve the issue. -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com. To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.