我在run.py
from emotion_classification_model import learningbased
import threading
def run_code():
threading.Timer(60.0, run_code).start()
learningbased()
run_code()
还有另一个insert.py
文件,其中包含
import MySQLdb
conn = MySQLdb.connect(host="localhost",user="root",passwd="",db="chat_app",use_unicode=True,charset="utf8")
x = conn.cursor()
def insert_result(insert_emotion):
x.execute('''INSERT into machinelearningresults (Emotion) values (%s)''', (insert_emotion))
conn.commit()
x.close()
def r_insert(rule_result):
x.execute('''INSERT into rulebasedresults (Emotion) values (%s)''', (rule_result))
conn.commit()
x.close()
conn.close()
当我调用insert_result(insert_emotion)
函数中的r_insert(rule_result)
和learningbased()
函数时,会出现以下错误。
raise errorclass, errorvalue _mysql_exceptions.ProgrammingError: cursor closed
任何人都可以帮我修复此错误。