So I am making an app in Flask and I am using RabbitMQ as message broker and also backend Celery worker. I also use SocketIO in order to report back the celery worker status to the client. 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 = 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 module
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".
Basically this is saying that without monkey patching, gevent is going to block when socket operations are issued. See http://www.gevent.org/gevent.monkey.html for more details about this.