redis / rq worker 在 python3 中断

redis / rq worker breaking on python3

所以我在 rq worker 中执行代码时遇到错误

 File "/usr/local/bin/rq", line 11, in <module>
   sys.exit(main())
 File "/usr/local/lib/python3.7/site-packages/click/core.py", line 764, in __call__
   return self.main(*args, **kwargs)
 File "/usr/local/lib/python3.7/site-packages/click/core.py", line 717, in main
   rv = self.invoke(ctx)
 File "/usr/local/lib/python3.7/site-packages/click/core.py", line 1137, in invoke
   return _process_result(sub_ctx.command.invoke(sub_ctx))
 File "/usr/local/lib/python3.7/site-packages/click/core.py", line 956, in invoke
   return ctx.invoke(self.callback, **ctx.params)
 File "/usr/local/lib/python3.7/site-packages/click/core.py", line 555, in invoke
   return callback(*args, **kwargs)
 File "/usr/local/lib/python3.7/site-packages/rq/cli/cli.py", line 75, in wrapper
   return ctx.invoke(func, cli_config, *args[1:], **kwargs)
 File "/usr/local/lib/python3.7/site-packages/click/core.py", line 555, in invoke
   return callback(*args, **kwargs)
 File "/usr/local/lib/python3.7/site-packages/rq/cli/cli.py", line 236, in worker
   worker.work(burst=burst, logging_level=logging_level)
 File "/usr/local/lib/python3.7/site-packages/rq/worker.py", line 493, in work
   self.execute_job(job, queue)
 File "/usr/local/lib/python3.7/site-packages/rq/worker.py", line 662, in execute_job
   self.fork_work_horse(job, queue)
 File "/usr/local/lib/python3.7/site-packages/rq/worker.py", line 599, in fork_work_horse
   self.main_work_horse(job, queue)
 File "/usr/local/lib/python3.7/site-packages/rq/worker.py", line 677, in main_work_horse
   success = self.perform_job(job, queue)
 File "/usr/local/lib/python3.7/site-packages/rq/worker.py", line 781, in perform_job
   self.prepare_job_execution(job)
 File "/usr/local/lib/python3.7/site-packages/rq/worker.py", line 706, in prepare_job_execution
   registry.add(job, timeout, pipeline=pipeline)
 File "/usr/local/lib/python3.7/site-packages/rq/registry.py", line 47, in add
   return pipeline.zadd(self.key, score, job.id)
 File "/usr/local/lib/python3.7/site-packages/redis/client.py", line 2263, in zadd
   for pair in iteritems(mapping):
 File "/usr/local/lib/python3.7/site-packages/redis/_compat.py", line 123, in iteritems
return iter(x.items())

AttributeError: 'int' object has no attribute 'items'
14:04:29 Moving job to 'failed' queue (work-horse terminated unexpectedly; waitpid returned 256)

我正在尝试 运行 在 openshift 上的解耦容器中使用此代码。相同的图像在本地工作。我想唯一的区别是我在本地尝试时 运行ning rq worker 在系统上而不是在容器上,而我的本地有 python 2 和 3 而 openshift 只有 python3。

任何人都可以解决为什么它开始表现得像这样。我怀疑它是由于 python 版本。但我不知道如何 运行 redis/ rq worker 与 python 2.

这是一个已知问题,由 redis-py 的新版本 3 引起 - 请参阅 https://github.com/rq/rq/issues/1014