gpt4 book ai didi

python - 集成 Tornado 与 celery : RuntimeError: tornado-redis must be installed to use the redis backend

转载 作者:可可西里 更新时间:2023-11-01 11:33:53 30 4
gpt4 key购买 nike

我在使用tornado-celery整合tornado和celery时,出现错误:```

traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/tornado/web.py", line 1369, in _stack_context_handle_exception
raise_exc_info((type, value, traceback))
File "/usr/local/lib/python2.7/dist-packages/tornado/stack_context.py", line 314, in wrapped
ret = fn(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/tornado/web.py", line 1581, in future_complete
f.result()
File "/usr/local/lib/python2.7/dist-packages/tornado/concurrent.py", line 215, in result
raise_exc_info(self._exc_info)
File "/usr/local/lib/python2.7/dist-packages/tornado/gen.py", line 876, in run
yielded = self.gen.throw(*exc_info)
File "/home/q/celeryTest/webui.py", line 18, in get
response = yield tornado.gen.Task(common_check.apply_async, args=[rids, None,None])
File "/usr/local/lib/python2.7/dist-packages/tornado/gen.py", line 870, in run
value = future.result()
File "/usr/local/lib/python2.7/dist-packages/tornado/concurrent.py", line 215, in result
raise_exc_info(self._exc_info)
File "/usr/local/lib/python2.7/dist-packages/tornado/gen.py", line 505, in Task
func(*args, callback=_argument_adapter(set_result), **kwargs)
File "/usr/local/lib/python2.7/dist-packages/celery/app/task.py", line 565, in apply_async
**dict(self._get_exec_options(), **options)
File "/usr/local/lib/python2.7/dist-packages/celery/app/base.py", line 354, in send_task
reply_to=reply_to or self.oid, **options
File "/usr/local/lib/python2.7/dist-packages/celery/app/amqp.py", line 310, in publish_task
**kwargs
File "build/bdist.linux-x86_64/egg/tcelery/producer.py", line 104, in publish
self.consumer.wait_for(task_id,
File "/usr/local/lib/python2.7/dist-packages/kombu/utils/__init__.py", line 325, in __get__
value = obj.__dict__[self.__name__] = self.__get(obj)
File "build/bdist.linux-x86_64/egg/tcelery/producer.py", line 118, in consumer
"tornado-redis must be installed to use the redis backend")
RuntimeError: tornado-redis must be installed to use the redis backend
ERROR:tornado.access:500 GET /check?rids=3001626 (127.0.0.1) 3.52ms

Tornado 代码是:

import tornado.web
import tornado.gen
import tcelery
from route_check_task.check_worker import common_check

tcelery.setup_nonblocking_producer()

class CheckHandler(tornado.web.RequestHandler):
@tornado.web.asynchronous
@tornado.gen.coroutine
def get(self):
rids = self.get_argument('rids').split(',')
print rids
response = yield tornado.gen.Task(common_check.apply_async, args=[rids, None,None])
self.write(str(response.result))
self.finish


application = tornado.web.Application([
(r"/check", CheckHandler),
])

if __name__ == "__main__":
application.listen(8889)
tornado.ioloop.IOLoop.instance().start()

celery 是:

@app.task
def common_check(rids, tts_enids, wrapperids):
check_list = load_checks()
results = []
rids_all = rids
if not rids_all or len(rids_all) == 0:
pre_results = check(check_list=check_list, rids=rids, tts_enids=tts_enids, wrapperids=wrapperids, ops=0)
results.append(pre_results)
else:
for i in xrange(0, len(rids_all), PRE_COUNT):
rids = rids_all[i: i + PRE_COUNT]
pre_results = check(check_list=check_list, rids=rids, tts_enids=tts_enids, wrapperids=wrapperids, ops=0)
results.append(pre_results)
logger_routecheck.info("check rids len={}".format(len(rids)))
print results
return results

错误提示我应该安装tornado-redis,但是我已经添加了,pip显示:

tornado (4.2)
tornado-celery (0.3.5)
tornado-redis (2.4.2)

我该如何解决这个问题,谢谢!

最佳答案

已解决,tornado-redis版本太低。当我更新版本到最新的:tornado-redis (2.4.18),一切正常。

关于python - 集成 Tornado 与 celery : RuntimeError: tornado-redis must be installed to use the redis backend,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37984445/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com