我正在尝试让Flask与Ceite一起使用SQLite作为后端.但是,使用以下代码:
CELERY_BROKER_URL = 'sqla+sqlite:///' + os.path.join(basedir, 'celery.db') def make_celery(app): celery = Celery(app.import_name, broker=app.config['CELERY_BROKER_URL']) celery.conf.update(app.config) TaskBase = celery.Task class ContextTask(TaskBase): abstract = True def __call__(self, *args, **kwargs): with app.app_context(): return TaskBase.__call__(self, *args, **kwargs) celery.Task = ContextTask return celery
启动一个worker后,我在尝试调用一个虚拟任务时遇到这个错误:
error: [Errno 10061] No connection could be made because the target machine actively refused it
码:
@app.route('/test') def test(): t = add_together.delay(100,200) return str(t.wait())
怎么了?我已经尝试使用Google搜索Sqllite/SQLAlchemy/Flask/Celery的任意组合,但一直无法找到解决方案.