torado,celery raise is not JSON serializable
代码就是这里了:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你应该设置的参数传递方式是json?
因该是传的参数里面有一些python对象,不能进行json的序列化,要么换一下参数类型,或者把传递方式换成pickle
和这个问题差不多https://github.com/mher/tornado-celery/issues/42
原因是only supports AMQP broker.