Answer the question
In order to leave comments, you need to log in
Who understands celery?
Trying to connect celery to flask gives an error
[2021-01-17 16:24:10,786: ERROR/MainProcess] consumer: Cannot connect to amqp://guest:**@127.0.0.1:5672// : [WinError 10061] No connection could be made because the target machine actively refused it.
app.config['CELERY_BROKER_URL'] = 'amqp://localhost//'
app.config['CELERY_BACKEND'] = 'db+sqlite:///project.db'
celery = make_celery(app)
from celery import Celery
def make_celery(app):
celery = Celery(app.import_name, backend=app.config['CELERY_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
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question