遇到一个问题,在使用"celery -A Redis worker --loglevel=info"命令启动时,报错
AttributeError: 'sys.flags' object has no attribute 'hash_randomization'
没找到具体是哪里的问题
我用的代码
# coding: utf-8
from celery import Celery
broker = 'redis://localhost:6379'
backend = 'redis://localhost:6379'
# "Redis" 任务名 (与当前文件名一致)
app = Celery("Redis", broker=broker, backend=backend)
@app.task()
def redis_main(x):
print "Hello %s!" % x
具体的报错
-------------- celery@DESKTOP-DK5Q8NF v4.2.0 (windowlicker)
---- **** -----
--- * *** * -- Windows-post2008Server-6.2.9200 2018-06-13 15:29:30
-- * - **** ---
- ** ---------- [config]
- ** ---------- .> app: Redis:0x5a88198
- ** ---------- .> transport: redis://localhost:6379//
- ** ---------- .> results: redis://localhost:6379/
- *** --- * --- .> concurrency: 4 (prefork)
-- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker)
--- ***** -----
-------------- [queues]
.> celery exchange=celery(direct) key=celery
[tasks]
. Redis.redis_main
[2018-06-13 15:29:31,095: CRITICAL/MainProcess] Unrecoverable error: AttributeError("'sys.flags' object has no attribute 'hash_randomization'",)
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\celery-4.2.0-py2.7.egg\celery\worker\worker.py", line 205, in start
self.blueprint.start(self)
File "C:\Python27\lib\site-packages\celery-4.2.0-py2.7.egg\celery\bootsteps.py", line 119, in start
step.start(parent)
File "C:\Python27\lib\site-packages\celery-4.2.0-py2.7.egg\celery\bootsteps.py", line 369, in start
return self.obj.start()
File "C:\Python27\lib\site-packages\celery-4.2.0-py2.7.egg\celery\concurrency\base.py", line 131, in start
self.on_start()
File "C:\Python27\lib\site-packages\celery-4.2.0-py2.7.egg\celery\concurrency\prefork.py", line 112, in on_start
**self.options)
File "C:\Python27\lib\site-packages\billiard-3.5.0.3-py2.7-win-amd64.egg\billiard\pool.py", line 1007, in __init__
self._create_worker_process(i)
File "C:\Python27\lib\site-packages\billiard-3.5.0.3-py2.7-win-amd64.egg\billiard\pool.py", line 1116, in _create_worker_process
w.start()
File "C:\Python27\lib\site-packages\billiard-3.5.0.3-py2.7-win-amd64.egg\billiard\process.py", line 124, in start
self._popen = self._Popen(self)
File "C:\Python27\lib\site-packages\billiard-3.5.0.3-py2.7-win-amd64.egg\billiard\context.py", line 383, in _Popen
return Popen(process_obj)
File "C:\Python27\lib\site-packages\billiard-3.5.0.3-py2.7-win-amd64.egg\billiard\popen_spawn_win32.py", line 55, in __init__
pipe_handle=rhandle)
File "C:\Python27\lib\site-packages\billiard-3.5.0.3-py2.7-win-amd64.egg\billiard\spawn.py", line 147, in get_command_line
opts = util._args_from_interpreter_flags()
File "C:\Python27\lib\site-packages\billiard-3.5.0.3-py2.7-win-amd64.egg\billiard\util.py", line 36, in _args_from_interpreter_flags
v = getattr(sys.flags, flag)
AttributeError: 'sys.flags' object has no attribute 'hash_randomization'