Skip to content

Commit 8ea8a1d

Browse files
committed
Add support for optimistic disconnect detection
1 parent d2d707b commit 8ea8a1d

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Diff for: sqlalchemy_sqlany/base.py

+9
Original file line numberDiff line numberDiff line change
@@ -837,3 +837,12 @@ def has_table(self, connection, table_name, schema=None):
837837
return False
838838
else:
839839
return True
840+
841+
def is_disconnect(self, e, connection, cursor):
842+
"""
843+
Signal to SQLAlchemy whether *e* indicates that *connection* is
844+
broken and the pool needs to be recycled.
845+
"""
846+
if isinstance(e, sqlanydb.OperationalError):
847+
return e.args[1] in (-101, -308,)
848+
return False

0 commit comments

Comments
 (0)