Thanks for this. As an update, I put in code that notifies me when an error
occurs. The real cause of this seems to still be the 'MySQL has gone away'
error. This occurs in various places, always as the first DB call in a
request (obviously).

Is my understanding correct that in order to solve this I have to make sure
that all DB calls do a session.close() or session.rollback() when finished?
Any thoughts on how to track which call is leaving the connection open?



On 31 October 2011 17:16, Michael Bayer <mike...@zzzcomputing.com> wrote:

>
> On Oct 31, 2011, at 12:56 PM, Benjamin Sims wrote:
>
> I suspect that my understanding of both threading and Sessions is going to
> be found pretty wanting here; I've basically just lifted things from
> Pyramid/SQLAlchemy examples.
>
> My understanding is that the framework handles threading, and that based
> on examples and
> http://www.sqlalchemy.org/docs/orm/session.html#contextual-thread-local-sessionsthis
>  is the correct way to create a session available throughout the
> request:
>
> DBSession =
> scoped_session(sessionmaker(extension=ZopeTransactionExtension()))
>
> (this is in my models file)
>
> I then use this either by doing:
>
> DBSession.query()
>
> or
>
> from models import DBSession
> session = DBSession()
> session.query()
>
> So, I'm not doing anything explicit in turns of ending the session - I
> guess I should be, but I had understood that this would happen on issue of
> next query/completion of request.
>
>
> that's a question for the Pyramid folks.     There should also be a single
> path for handling of exceptions - any unexpected exception would propagate
> to the same point, there's a Session.rollback() right there, and it gets
> reported.
>
>  --
> 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.
>

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