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

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

所以我在 Flask 中制作了一个应用程序,我使用 RabbitMQ 作为消息代理和后端 Celery worker。我还使用 SocketIO 向客户端报告 celery worker 状态。当我 运行 我的应用程序时,出现以下错误:

如果您告诉我为什么会出现此错误,我将不胜感激。

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

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

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

哎呀,错误信息已经copy/pasted来自另一个模块,我忘记更新了。该消息应该是 "Kombu requires a monkey patched socket library to work with gevent".

基本上这就是说如果没有猴子补丁,gevent 将在发出套接字操作时阻塞。有关详细信息,请参阅 http://www.gevent.org/gevent.monkey.html