def ping_connection(connection, branch):
if branch:
# Don't ping sub-connections
return
try:
# Test the connection
connection.scalar(select([1]))
except exc.DBAPIError as e:
if e.connection_invalidated:
# Establish a new connection
connection.scalar(select([1]))
else:
raise
评论列表
文章目录