On 6/29/15 2:33 PM, Andy Crain wrote:
But these seem heavy handed and wrong. What I’d like to do is just
discard this stale connection (in my session and in the pool) and get
a fresh one, but I can’t determine how to.
at the bottom of that section, the important part is about invalidation:
http://docs.sqlalchemy.org/en/rel_1_0/core/pooling.html#more-on-invalidation
specifically invalidate():
http://docs.sqlalchemy.org/en/rel_1_0/core/connections.html?highlight=invalidate#sqlalchemy.engine.Connection.invalidate
from session:
session.connection().invalidate()
however, you've now killed off your transaction, and you will lose
whatever isn't committed on it. If you don't need the transaction to
last this long, then you shouldn't have a connection checked out - the
Session only has a connection checked out when you are in a
transaction. So I think the original assertion "due to some unavoidable
long-running code" doesn't really make any sense, especially if you are
using an ORM Session. If this isn't impacting you because you are on
MyISAM and are essentially using autocommit, then just set your Session
to use autocommit:
http://docs.sqlalchemy.org/en/rel_1_0/orm/session_transaction.html#autocommit-mode;
no more stale connections.
Thanks for any help.
Andy
--
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]
<mailto:[email protected]>.
To post to this group, send email to [email protected]
<mailto:[email protected]>.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.
--
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 http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.