def run_conn_fun(fun,*args):
try:
global conn
result=yield getattr(conn,fun)(*args)
except (MySQLdb.OperationalError,adbapi.ConnectionLost):
try:
conn.close()
except:
pass
conn=adbapi.ConnectionPool("MySQLdb",host=MYSQLCONFIG["host"],user=MYSQLCONFIG["user"],passwd=MYSQLCONFIG["passwd"],charset=MYSQLCONFIG["charset"],port=MYSQLCONFIG["port"],db=MYSQLCONFIG["db"],cp_reconnect=True)
result=yield getattr(conn,fun)(*args)
defer.returnValue(result)
评论列表
文章目录