Hi, Currently working on a project that use SQL alchemy with mod_wsgi, webapp2 and prestans (python REST framework). The backend is Oracle XE using cx_Oracle.
What is the appropriate way to manage sessions in a multithreading app such as this? Currently I have been following the guide found here<http://docs.sqlalchemy.org/en/rel_0_7/orm/session.html#contextual-thread-local-sessions> to implement a contextual/thread-local session. I have then made a session that is automatically cleaned up by the request handler. The code for this looks something like: def dispatch(self): self.db_session = db.Session() super(BaseHandler, self).dispatch() self.db_session.close() db.Session.remove() However this doesn't seem to clean up all database connections as viewed in netstat and I get a connections exhausted error from Oracle XE after a certain time of using the application. The same thing also happens when I use MySQL as well. If I add a call to db.engine.dispose() after the handler has returned this appears to fix the problem but the SQL Alchemy documentation indicates that this is only for usage with dropped connections or in test suites. What is the best practice for usage of a session in a multithreading application that ensures connections are cleaned up? Thanks, Brad -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/JX4p9ik0XKkJ. 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.