Hi Mike,

Thanks for the reply!

On Mon, Jun 7, 2021 at 6:08 PM Mike Bayer <mike...@zzzcomputing.com> wrote:

> ORM Sessions ride on top of connections, but since the Session under it's
> default pattern of being bound to an Engine does the "connect" internally,
> it's probably inconvenient to adapt the optimistic disconnect approach to
> it.     You would probably want to bind the Session to the Connection
> explicitly.
>

I searched the SA docs, but could not find how to bind the Session to the
Connection.


>   however, I would advise using pool_pre_ping instead which is much easier
> to use and has basically no downsides.    this feature didn't exist when
> the docs for "optimistic disconnect" were written.
>

Sure. I was only looking at doing the optimistic disconnect because it
seemed a little more resilient to failures (if a DB error happens mid
transaction) and because I felt I could control the number of retries and
put in an exponential backoff.

Do you suggest I use the custom pessimistic ping code:

https://docs.sqlalchemy.org/en/14/core/pooling.html#custom-legacy-pessimistic-ping

to add in exponential backoff or add additional retries?

Thank you again for the help!

-m

-- 
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/CAOLfK3WYSinbhQLbMaBTf7sRRDZ8PtVcQ6u2-gV4ftjS36ZstA%40mail.gmail.com.

Reply via email to