Exemple #1
0
 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)
Exemple #2
0
	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)