Celery Worker solve the problem can not be started by the root user

First, the error demo

(venv) [root@localhost celery_tasks]# celery -A tasks worker -l info
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
(venv) [root@localhost celery_tasks]# 

translate

当worker接受用pickle序列化的消息时,以超级用户权限运行worker是一个非常糟糕的主意!

如果您确实要继续,则必须设置C_FORCE_ROOT
环境变量(但请在使用前先考虑一下)。

用户信息:uid = 0 euid = 0 gid = 0 egid = 0

Second, the problem is solved

  1. Method One: temporarily solve the problem
    on the server, enter the following command

    export C_FORCE_ROOT="true"
    
  2. Method two: permanent solution to the problem

    from celery import Celery,platforms #导入platforms
    app = Celery('celery_tasks.tasks', broker='redis://127.0.0.1:6379/1')
    platforms.C_FORCE_ROOT = True #加上这一行
    @app.task
    def test():
    	pass
    
Welcome attention of the same name micro-channel public number: Program ape Miscellany

Program ape Miscellany

Technology | exchange | welfare
Published 63 original articles · 87 won praise · views 40000 +

Guess you like

Origin blog.csdn.net/weixin_44110998/article/details/103495184