Timer(10, remove_code, (code, time.time())).start()
def remove_code(code, v): print("删除 code:" + str(code)) exist_code = Code.query.filter_by(Code.code == code).first() if exist_code: db.session.delete(exist_code) db.session.commit()
RuntimeError: No application found. Either work inside a view function or push an application context.
是因为在 timer 里面拿不到 Context 吗,所以在 db 操作的时候报错?有大神讲解一下吗?