我正在尝试使用celery == 3.1.25(Python 2.7)来分别对我的主烧瓶应用程序运行一些昂贵的任务。但是,当我使用celery -A run.celery worker --loglevel=info
启动celery worker时,该过程失败,并显示以下信息:
[ERROR/MainProcess] Process 'Worker' exited with 'exitcode 1'
这是我的文件结构:
app/
__init__.py
celery_functions.py
routes.py
...
run.py
run.py:
from app import create_app
from app.config import Config
from celery import Celery
app = create_app('default')
app.app_context().push()
from app.routes import *
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000)
__ init __。py:
from flask import Flask
from flask_bootstrap import Bootstrap
from config import Config
def create_app(config_name):
app = Flask(__name__)
app.config.from_object(config[config_name])
bootstrap = Bootstrap(app)
return app
celery_functions.py:
import celery
@celery.task(name='celery_functions.archive_repo')
def archive_repo():
# do something
routes.py:
from celery_functions import *
@app.route('/archive', methods=['GET', 'POST'])
@login_required
def archive():
archive_repo.delay()
return ''