Hi Jonathan, Thanks for your response, i removed the newresponse event like you mentioned and added a finished callback to the request (in a tween): request.add_finished_callback(cleanup_db_session) Unfortunatly the plot thickens! Since the last time i tested our project, the problem *doesn't* occur anymore using waitress, cogen or gunicorn (in sync mode), they all handle all requests i spam correctly... but it now consistently raise an "(InterfaceError) cursor already closed" exception on ~80% of the requests when using gunicorn (in gevent mode). It actually doesn't seem to make any difference wether i use db_session.remove() or not! Could gunicorn's gevent mode have any effect on the application layer? Any other ideas? Matthijs
On Wednesday, 10 September 2014 18:18:42 UTC+2, Jonathan Vanasco wrote: > 1. I had a concern a few months ago when doing an audit of code. I ended > up not having an issue, but this link might be of help: > > https://groups.google.com/d/topic/sqlalchemy/Z7tMCB_IK1M/discussion > > 2. I use `add_finished_callback`, which runs unconditionally at the end > of every request. > > request.add_finished_callback(cleanup_db_session) > > Actually, I think this may be caused or exacerbated by your use of > `NewRespsone`. I think that event can be triggered multiple times during a > single request, and if you generate multiple response objects, only the > first one would have an active connection. > -- 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 sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at http://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.