简体   繁体   English

Flask Socket.IO给Redis错误,但我正在使用RabbitMQ

[英]Flask Socket.IO giving Redis error but I am using RabbitMQ

So I am making an app in Flask and I am using RabbitMQ as message broker and also backend Celery worker. 因此,我在Flask中制作了一个应用程序,并在使用RabbitMQ作为消息代理和后端Celery worker。 I also use SocketIO in order to report back the celery worker status to the client. 我还使用SocketIO以便向客户端报告芹菜工作者的状态。 When I am running my app I get the following error: 当我运行我的应用程序时,出现以下错误: 在此处输入图片说明

I appreciate if you let me know why do I get this error. 如果您让我知道为什么会出现此错误,我们将不胜感激。

app.py app.py

app = Flask(__name__)
app.config['SECRET_KEY'] = ''

app.config.update(
CELERY_BROKER_URL = 'amqp://localhost//',
CELERY_RESULT_BACKEND='amqp://localhost//'
)

socketio = SocketIO(app, message_queue='amqp://')
celery = make_celery(app)


@app.route('/')
def my_form():
    return render_template("form.html")

JavaScript 的JavaScript

var socket = io.connect(location.protocol + '//' + document.domain + ':' + location.port );

make_celery module make_celery模块

def make_celery(app):
    celery = Celery(app.import_name, backend=app.config['CELERY_RESULT_BACKEND'],
                    broker=app.config['CELERY_BROKER_URL'])
    celery.conf.update(app.config)
    TaskBase = celery.Task
    class ContextTask(TaskBase):
        abstract = True
        def __call__(self, *args, **kwargs):
            with app.app_context():
                return TaskBase.__call__(self, *args, **kwargs)
    celery.Task = ContextTask
    return celery

Oops, the error message has been copy/pasted from another module, and I forgot to update it. 糟糕,错误消息已从其他模块复制/粘贴,我忘了更新。 The message should have read "Kombu requires a monkey patched socket library to work with gevent". 该消息应显示为“ Kombu需要一个猴子修补套接字库才能使用gevent”。

Basically this is saying that without monkey patching, gevent is going to block when socket operations are issued. 基本上这就是说,如果没有猴子补丁,gevent将在发出套接字操作时阻塞。 See http://www.gevent.org/gevent.monkey.html for more details about this. 有关更多详细信息,请参见http://www.gevent.org/gevent.monkey.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM