celery3.1.25
python3.7
语法错误
本地调试是python3.6
将环境切换成3.6.8
miniconda 环境 执行 服务
# /etc/supervisor/conf.d/hello.ini
[program:hello]
command=/usr/bin/mod_wsgi-express start-server --log-level debug --server-root /www/wsgi.run/hello --host 0.0.0.0 --port 29032 --user apache app.py
directory=/www/wsgi/hello
environment=prometheus_multiproc_dir="/data/prometheus/hello"
[program:hello.celeryapp]
# 切换成apache用户执行,否则无法在相应目录生成文件,会有权限问题
user=apache
command=/data/miniconda3/envs/e.py36/bin/celery worker -A app.celery --loglevel=debug -f /www/wsgi.run/hello/celeryworker.log
directory=/www/wsgi/hello
environment=PATH="/data/miniconda3/envs/e.py36/"
(e.py36) [root@10-10-91-95 hello]# /data/miniconda3/envs/e.py36/bin/celery worker -A app.celery --loglevel=debug -f /www/wsgi.run/hello/celeryworker.log
Running a worker with superuser privileges when the
worker accepts messages serialized with pickle is a very bad idea!
If you really want to continue then you have to set the C_FORCE_ROOT
environment variable (but please think about this before you do).
User information: uid=0 euid=0 gid=0 egid=0
(e.py36) [root@10-10-91-95 logsearchapi]#
解决方法:
celery3.1中的变量asyn,在python3.7中是关键字,直到celery4,没有对变量async改名。换句话说即使celery4与python3.7配合使用,仍然会出现这个问题。
因此需要将将python降级成python3.6版本
兼容问题:
https://stackoverflow.com/questions/50511905/cannot-start-celery-worker-kombu-asynchronous-timer
http://www.beixiongxiong.com/course/10103254/2129/
https://www.twblogs.net/a/5d0517b1bd9eee47d34bda4b/zh-cn