本文整理汇总了Python中twisted.enterprise.adbapi.ConnectionPool._runInteraction方法的典型用法代码示例。如果您正苦于以下问题:Python ConnectionPool._runInteraction方法的具体用法?Python ConnectionPool._runInteraction怎么用?Python ConnectionPool._runInteraction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.enterprise.adbapi.ConnectionPool
的用法示例。
在下文中一共展示了ConnectionPool._runInteraction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _runInteraction
# 需要导入模块: from twisted.enterprise.adbapi import ConnectionPool [as 别名]
# 或者: from twisted.enterprise.adbapi.ConnectionPool import _runInteraction [as 别名]
def _runInteraction(self, interaction, *args, **kw):
try:
return ConnectionPool._runInteraction(self, interaction, *args, **kw)
except MySQLdb.OperationalError as e:
if e[0] not in (2006, 2013, 1213):
raise
# 2006 MySQL server has gone away
# 2013 Lost connection to MySQL server
# 1213 Deadlock found when trying to get lock; try restarting transaction
log.msg("%s got error %s, retrying operation" % (self.__class__.__name__, e))
conn = self.connections.get(self.threadID())
self.disconnect(conn)
# try the interaction again
return ConnectionPool._runInteraction(self, interaction, *args, **kw)
except MySQLdb.InterfaceError as e:
if e[0] not in (0,):
raise
# 0 Interface error (conn gone away or closed)
log.msg("%s got error %s, retrying operation" % (self.__class__.__name__, e))
conn = self.connections.get(self.threadID())
self.disconnect(conn)
# try the interaction again
return ConnectionPool._runInteraction(self, interaction, *args, **kw)