celery不能root用户启动解决(C_FORCE_ROOT environment)

发布时间 2023-04-08 09:30:08作者: 一先生94

celery不能root用户启动解决(C_FORCE_ROOT environment)

 

 

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).

解决方法

from celery import Celery, platforms

app = Celery('tasks', broker='amqp://myuser:

mypassword@localhost :5672/vhost')

platforms.C_FORCE_ROOT = True #加上这一行

@app.task
def add(x, y):
return x + y

添加:

platforms.C_FORCE_ROOT = True #加上这一行即可