if your application is in some kind of loop that wants a single Session to 
recover after an exception, part of that loop's construction should ensure 
exceptions are handled appropriately. and the session's state is reset.   Like 
the docs mention, this is trivial for web applications, all of which provide 
systems for init/cleanup on request.

Its a little misleading to say "I need to wrap *all* DB code in a try/except", 
since you definitely don't want ad-hoc try/excepts everywhere.      If your app 
already has exceptions raised and keeps on going, then its a given that you 
already have a "try/except" block somewhere in your application doing that.


On Feb 25, 2011, at 6:49 AM, Romy wrote:

> Hey Michael,
> 
> Just had a "MySQL has gone away" that I intentionally triggered by
> setting the pool recycle to be higher than wait_timeout. Afterwards, I
> watched the commit() at the end of the request throw a "Can't
> reconnect until invalid transaction is rolled back", which the catch
> block was handling with a rollback() followed by a raise. Then it got
> stuck in that state.
> 
> This made me realize -- do I need to wrap *all* DB code inside try/
> catch blocks ? Because currently it's only the commit() at the end of
> each request that gets wrapped. Outside of "gone away" errors, are
> there other errors that will get the process stuck in the "can't
> reconnect until rollback" state ?
> 
> If so, it might be a pain in the ass to wrap all requests without
> modifying the framework.
> 
> R
> 
> -- 
> 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.
> 

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

Reply via email to