Great, thanks for the info. On Friday, November 26, 2021 at 9:30:02 AM UTC-8 Mike Bayer wrote:
> I've spent some time thinking about what might be being asked here. the > only thing I can think of is that when a particular database connection is > found to be in what we call a "disconnect" state, the connection is > invalidated, so that the connection will reconnect and make a new > connection. But also, this operation will typically assume the > "disconnect" condition is that the database was restarted, or some other > network condition has probably made all the connections that are pooled > also invalid. So the entire pool will be invalidated in this case as well. > > Why someone might want to turn that off is if they are getting lots of > invalidated connections for some other reason and they are not able to > solve that problem, so they'd like the pool to not be invalidated totally. > This means that if the database is restarted, and for example you have 20 > pooled connections, you will in a high-request environment get up to 20 > server errors unless pool_pre_ping is turned on so that the connections are > refreshed one at at time. > > To disable the pool invalidation upon receipt of a single connection shown > to be in a disconnect, implement the handle_error event: > https://docs.sqlalchemy.org/en/14/core/events.html#sqlalchemy.events.ConnectionEvents.handle_error > > and then set invalidate_pool_on_disconnect to False: > https://docs.sqlalchemy.org/en/14/core/connections.html?highlight=invalidate_pool_on_disconnect#sqlalchemy.engine.ExceptionContext.invalidate_pool_on_disconnect > > . > > > > On Fri, Nov 26, 2021, at 11:51 AM, Mike Bayer wrote: > > Im not sure if I understand the question? if you don't call > .invalidate(), then the connection is not invalidated. > > what does "turn off" mean ? > > > > On Fri, Nov 26, 2021, at 11:17 AM, Anupama Goparaju wrote: > > Hi, > > Is there a way to safely turn off connection invalidation functionality > (based on invalidation time set, all the connections created prior to the > timestamp are invalidated) in sqlalchemy? > > > https://github.com/Noethys/Connecthys/blob/master/connecthys/lib/sqlalchemy/pool.py#L574 > > Thanks, > Anupama > > > -- > 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 sqlalchemy+...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/sqlalchemy/07c76e07-17d4-4cea-9e42-1965ad80a06fn%40googlegroups.com > > <https://groups.google.com/d/msgid/sqlalchemy/07c76e07-17d4-4cea-9e42-1965ad80a06fn%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > > > -- > 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 sqlalchemy+...@googlegroups.com. > > To view this discussion on the web visit > https://groups.google.com/d/msgid/sqlalchemy/a1807f9d-e0c4-4ee6-9c03-ff2a56afeded%40www.fastmail.com > > <https://groups.google.com/d/msgid/sqlalchemy/a1807f9d-e0c4-4ee6-9c03-ff2a56afeded%40www.fastmail.com?utm_medium=email&utm_source=footer> > . > > > -- 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 sqlalchemy+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/sqlalchemy/18161d34-4d96-4af2-8ec1-83b47db89516n%40googlegroups.com.