2006, 'MySQL server has gone away'
描述:mysql服務端斷開idle過期連線,而客戶沒有檢測重連所以報錯。
解決:
def is_connection_usable(): try: connection.connection.ping() except: return False else: return True def do_queue(): while True: if not is_connection_usable(): connection.close() # do long time task