On Wed, Jan 17, 2018 at 12:21 AM, Jonathan Vanasco <[email protected]> wrote: > > > On Tuesday, January 16, 2018 at 6:26:34 PM UTC-5, Mike Bayer wrote: > >> dispose() is not needed inside of a web context. however, the kind >> of web container you're using as well as if you are using something >> like gevent or eventlet may be significant in why you are getting idle >> transactions. > > > Mike- I thought `dispose()` was necessary with forking webservers if > connections are made *before* the process forked, because the servers > (typically) implement fork() behind the scenes. uwsgi offers a @postfork > decorator (and an explicit hook) that I use to call the dispose(), and > gunicorn has a `post_fork` hook. i don't recall the specifics of other > servers.
if you create your engine in your parent process, and then let that engine travel into a fork(), then yes, you need to call dispose() just once when the fork starts, so that you get new connections in your forked process. I mentioned that above. however, there's a neater way that we do this in openstack which I also refer to above in the pooling docs, that is to use an event to track which process a particular connection was created within, and invalidate it if the two don't match. yet another thing that could be just added to the pool :) create_engine(..., protect_across_forks=True) > > -- > SQLAlchemy - > The Python SQL Toolkit and Object Relational Mapper > > http://www.sqlalchemy.org/ > > To post example code, please provide an MCVE: Minimal, Complete, and > Verifiable Example. See http://stackoverflow.com/help/mcve for a full > description. > --- > 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 https://groups.google.com/group/sqlalchemy. > For more options, visit https://groups.google.com/d/optout. -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- 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 https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
