torado,celery raise is not JSON serializable

发布于 2022-08-31 20:24:05 字数 3091 浏览 19 评论 0

代码就是这里了:
https://github.com/mher/tornado-celery/

报错:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/tornado-4.0.2-py2.7-linux-x86_64.egg/tornado/web.py", line 1288, in _stack_context_handle_exception
raise_exc_info((type, value, traceback))
File "/usr/local/lib/python2.7/dist-packages/tornado-4.0.2-py2.7-linux-x86_64.egg/tornado/web.py", line 1475, in wrapper
result = method(self, *args, **kwargs)
File "examples/tornado_async.py", line 14, in get
tasks.sleep.apply_async(args=[3], callback=self.on_result)
File "/usr/local/lib/python2.7/dist-packages/celery-3.1.17-py2.7.egg/celery/app/task.py", line 555, in apply_async
**dict(self._get_exec_options(), **options)
File "/usr/local/lib/python2.7/dist-packages/celery-3.1.17-py2.7.egg/celery/app/base.py", line 353, in send_task
reply_to=reply_to or self.oid, **options
File "/usr/local/lib/python2.7/dist-packages/celery-3.1.17-py2.7.egg/celery/app/amqp.py", line 305, in publish_task
**kwargs
File "/usr/local/lib/python2.7/dist-packages/kombu-3.0.24-py2.7.egg/kombu/messaging.py", line 168, in publish
routing_key, mandatory, immediate, exchange, declare)
File "/usr/local/lib/python2.7/dist-packages/kombu-3.0.24-py2.7.egg/kombu/connection.py", line 436, in _ensured
return fun(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/kombu-3.0.24-py2.7.egg/kombu/messaging.py", line 184, in _publish
mandatory=mandatory, immediate=immediate,
File "/usr/local/lib/python2.7/dist-packages/kombu-3.0.24-py2.7.egg/kombu/transport/virtual/__init__.py", line 521, in basic_publish
message, exchange, routing_key, **kwargs
File "/usr/local/lib/python2.7/dist-packages/kombu-3.0.24-py2.7.egg/kombu/transport/virtual/exchange.py", line 61, in deliver
_put(queue, message, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/kombu-3.0.24-py2.7.egg/kombu/transport/redis.py", line 673, in _put
client.lpush(self._q_for_pri(queue, pri), dumps(message))
File "/usr/local/lib/python2.7/dist-packages/anyjson-0.3.3-py2.7.egg/anyjson/__init__.py", line 141, in dumps
return implementation.dumps(value)
File "/usr/local/lib/python2.7/dist-packages/anyjson-0.3.3-py2.7.egg/anyjson/__init__.py", line 87, in dumps
return self._encode(data)
File "/usr/lib/python2.7/json/__init__.py", line 231, in dumps
return _default_encoder.encode(obj)
File "/usr/lib/python2.7/json/encoder.py", line 201, in encode
chunks = self.iterencode(o, _one_shot=True)
File "/usr/lib/python2.7/json/encoder.py", line 264, in iterencode
return _iterencode(o, 0)
File "/usr/lib/python2.7/json/encoder.py", line 178, in default
raise TypeError(repr(o) + " is not JSON serializable")
TypeError: is not JSON serializable

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

∞觅青森が 2022-09-07 20:24:05

你应该设置的参数传递方式是json?
因该是传的参数里面有一些python对象,不能进行json的序列化,要么换一下参数类型,或者把传递方式换成pickle

你的心境我的脸 2022-09-07 20:24:05

和这个问题差不多https://github.com/mher/tornado-celery/issues/42
原因是only supports AMQP broker.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文