On Apr 3, 10:13 am, "Michael Bayer" <mike...@zzzcomputing.com> wrote:
> Josh Winslow wrote:
>
> > On Apr 2, 9:21 pm, Michael Bayer <zzz...@gmail.com> wrote:
> >> On Apr 2, 4:41 pm, Josh Winslow <jwins...@gmail.com> wrote:
>
> >> > This is the stack trace:
> >> > ====================
> >> > ⇝  InvalidRequestError: The transaction is inactive due to a
> >> rollback
> >> > in a subtransaction. Issue rollback() to cancel the transaction.
> >> > clear this
>
> >> you are squelching the original exception somewhere.    this error
> >> only occurs after an exception has already been raised, and the
> >> Session is used again without resetting its state.
>
> > So this belongs on the Pylons list?  Because it literally is the first
> > possible query of the request.  It only occurs in periods of high load
> > and it seems like the contextual session is getting reused for a new
> > web request.
>
> theres an error being raised likely in a previous request within the same
> thread.  it should be in your logs.
>
> Do your BaseController like this (and please get the pylons ppl to
> document this if they haven't already):
>
> class BaseController(WSGIController):
>
>     def __call__(self, environ, start_response):
>         """Invoke the Controller"""
>         try:
>             return WSGIController.__call__(self, environ, start_response)
>         except:
>             meta.Session.rollback()
>             raise
>         finally:
>             meta.Session.remove()

I already had the finally block set, though not the rollback on the
exception.  From my reading of the documentation at
http://www.sqlalchemy.org/docs/05/session.html#contextual-thread-local-sessions
it would appear that doing a remove in a finally block should be
sufficient.  I'll throw the except line in however, and see if that
resolves the problem.

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to