router.py 文件源码

python
阅读 28 收藏 0 点赞 0 评论 0

项目:dcmha 作者: wwwbjqcom 项目源码 文件源码
def CheckConn(self,port):
        retry_num = 0
        while True:
            try:
                local_conn = MySQLdb.connect(host='127.0.0.1', user=mysql_user, passwd=mysql_password, port=int(port), db='',charset="utf8")
                local_conn.cursor()
                local_conn.close()
                state = True
                break
            except MySQLdb.Error,e:
                logging.error(e)
                state = None
            retry_num += 1
            time.sleep(1)
            if retry_num >= 3:
                break
        return  state
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号