Z
Z
zyusifov112021-01-17 15:30:09
Celery
zyusifov11, 2021-01-17 15:30:09

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)

in celery settings
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

60042dceab0ac574049874.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2021-01-17
@zyusifov11

RabbitMQ is not running on the host.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question