Celery错误“预期为0xce时收到0x00". [英] Celery error "Received 0x00 while expecting 0xce"

查看:72
本文介绍了Celery错误“预期为0xce时收到0x00".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用芹菜.我已经通过celery教程中的命令安装了 rabbit-mq :

I try to use celery. I have installed rabbit-mq by command from celery tutorial:

sudo apt-get install rabbitmq-server

当我在一个文件中编写代码并运行它以测试功能时,所有方法都运行良好.但是,当我尝试在Django视图中添加代码,然后对视图进行并发请求时,出现了这种异常:

And all worked well while I write my code in one file and run it to test functionality. But when I tried to add my code in Django views, and then to do concurrent requests to my views, I got this kind of exception:

File "/home/kinmanz/PycharmProjects/GitFace/myvenv/lib/python3.5/site-packages/amqp/connection.py", line 464, in drain_events
    return self.blocking_read(timeout)
  File "/home/kinmanz/PycharmProjects/GitFace/myvenv/lib/python3.5/site-packages/amqp/connection.py", line 468, in blocking_read
    frame = self.transport.read_frame()
  File "/home/kinmanz/PycharmProjects/GitFace/myvenv/lib/python3.5/site-packages/amqp/transport.py", line 251, in read_frame
    'Received {0:#04x} while expecting 0xce'.format(ch))
amqp.exceptions.UnexpectedFrame: Received 0x00 while expecting 0xce

我认为问题可能出在请求的并发上,我应该以某种方式使队列并发安全.

I think that problem may be in concurrency of request, and I should somehow to make queue concurrent safe.

我使用Python 3.5,Celery 4.0.0,RabbitMQ 3.5.7

I use Python 3.5, Celery 4.0.0, RabbitMQ 3.5.7

amqplib 中的实际问题,请参见下面的答案.

Actually problem in amqplib see answer below.

推荐答案

可能是针对有相同问题的人,我将列出设法找到的可能解决方案.如果您知道更好的解决方案,请添加您的答案或发表评论.

May be for someone who has the same problem, I will list possible solutions that I have managed to find. If you know better solution please add your answer or comment mine.

如果您使用的是 Python 2.x ,则看到该问题https://github.com/celery/celery/issues/922 amqplib 中的问题,实际上如果在 librabbitmq 上进行了更改,则所有问题都应该起作用,这很容易做到,请参见: Celery 3.0.1中的框架错误

If you are using Python 2.x then see that issue https://github.com/celery/celery/issues/922 problem actually in amqplib if it change on librabbitmq all should be working, it's quite easy to do, see: Framing Errors in Celery 3.0.1

但是,如果您使用的是 Python 3.x ,则无法以这种方式解决该问题,因为没有可用的Python 3兼容的 librabbitmq ,请注意问题 https://github.com/celery/celery/issues/2066 但在在这种情况下,您可以在 redis 上更改结果后端,例如:

But if you are using Python 3.x you can't solve that problem in that way, because there is no Python 3-compatible librabbitmq available, see that issue https://github.com/celery/celery/issues/2066 but in that case you can change your result backend on redis for example:

1)安装Redis服务器:

1) Install redis server:

$ sudo aptitude install redis-server

2)更改您的应用配置

2) Change your app configuration

app = Celery('tasks', backend='redis://localhost', broker='pyamqp://')

关于安装 redis 的一些有用链接:

Some useful links about installation redis: Setting up an asynchronous task queue for django using celery redis and Celery-redis quick guide

对于 Python 3 ,您也可以尝试在 Python 3 上运行应用程序时在 Python 2.7 中运行celery worker.不要忘记安装 librabbitmq 而不是 amqplib .(这种方式似乎很不方便)

Also for Python 3 you can try to run celery worker in Python 2.7 while your app is working on Python 3, in that case don't forget install librabbitmq instead of amqplib. (This way seems to be inconvenient)

这篇关于Celery错误“预期为0xce时收到0x00".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆