Skip to content

Commit 41c266b

Browse files
authored
Merge pull request #7 from hynek/master
Add support for optimistic disconnect detection
2 parents 4e55f19 + 8ea8a1d commit 41c266b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

sqlalchemy_sqlany/base.py

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

0 commit comments

Comments
 (0)