On Wednesday, 4 June 2014 04:16:00 UTC+2, Michael Bayer wrote: > > to my knowledge, Tornado does not use threads. It bundles all requests > into an async chain in one thread. So the usage of scoped_session() > without any specific request context is not valid in that context, it will > be linking a Session to the current thread which in an async system would > be a disaster, the same session would get mixed into random requests. > that is, the on_finish() handler of one request will blow away the current > contextual session, which calls close(), which means an already executing > thread that calls upon self.session.commit() would see an empty session. > > Please review > http://docs.sqlalchemy.org/en/rel_0_9/orm/session.html#thread-local-scope > for what “thread local” means in terms of SQLAlchemy. >
You are right. Turns out I needed to make the scope function depending on the actual request instead as described here http://amitmatani.com/scoping-sqlalchemys-session-while-using-tornado-dot-gen -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
