문제

'MySQL 서버가 사라졌습니다'오류를 디버깅하고 있습니다.더 많거나 적은 제안 된 솔루션이 있습니다 :

from twisted.enterprise import adbapi
from twisted.python import log
import MySQLdb

class ReconnectingConnectionPool(adbapi.ConnectionPool):
    """Reconnecting adbapi connection pool for MySQL.

    This class improves on the solution posted at
    http://www.gelens.org/2008/09/12/reinitializing-twisted-connectionpool/
    by checking exceptions by error code and only disconnecting the current
    connection instead of all of them.

    Also see:
    http://twistedmatrix.com/pipermail/twisted-python/2009-July/020007.html

    """
    def _runInteraction(self, interaction, *args, **kw):
        try:
            return adbapi.ConnectionPool._runInteraction(self, interaction, *args, **kw)
        except MySQLdb.OperationalError, e:
            if e[0] not in (2006, 2013):
                raise
            log.msg("RCP: got error %s, retrying operation" %(e))
            conn = self.connections.get(self.threadID())
            self.disconnect(conn)
            # try the interaction again
            return adbapi.ConnectionPool._runInteraction(self, interaction, *args, **kw)
.

여기에서 가져온 것 : http://www.gelens.org/2009/09/13/꼬인 연결 풀 - 재검토 /

그러나 예외는 ReconnectingConnectionPool에서만 _하지만 _runInteraction 자체에도 없게됩니다.그리고 그것은 log.err, (분명히) 두 가지가있는 log.err을 트리거합니다 :

  • 오류를 인쇄합니다 - 우리의 응용 프로그램은 잘 작동하지만
  • 더 나쁜 것은 재판을 실패하므로 테스트가 실패합니다.나는 이것이 이것이 log.err 문제이지만 그럼에도 불구하고 일어나는 일이 아닙니다.

나는 Adbapi를 해킹 할 수 있지만, 그것은 아마도 최선의 아이디어가 아닐 것입니다.이것을 처리 할 수있는 더 좋은 방법이 있습니까?

도움이 되었습니까?

해결책

오류가 기록 된 경우에도 단위 테스트 패스를 만드는 방법을 묻는 것입니까? "Nofollow"> FlushLoggedErrors .다른 것을 묻는다면 명확히하십시오.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top