Добрый день. Настраиваю Django + Celery + RabbitMQ. Но задачи не выполняются асинхронно
celery.pyimport os
from celery import Celery
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'shop.settings')
app = Celery('shop')
# Configurations
app.config_from_object('django.conf:settings')
app.autodiscover_tasks()
__init__.pyfrom __future__ import absolute_import
from .celery import app as celery_app
__all__ = ['celery_app']
tasks.pyfrom celery import task
from django.core.mail import EmailMessage
from django.template.loader import get_template
from .models import Order
@task
def send_order_email(order_id):
order = Order.objects.get(pk=order_id)
template = get_template('order/email_order.html')
html = template.render({'order': order})
# Create & Send Email
msg = EmailMessage(...)
msg.content_subtype = 'html'
msg.send()
Как я запускаю все:
RabbitMQ:RabbitMQ 3.6.9. Copyright (C) 2007-2016 Pivotal Software, Inc.
## ## Licensed under the MPL. See http://www.rabbitmq.com/
## ##
########## Logs: /usr/local/var/log/rabbitmq/rabbit@localhost.log
###### ## /usr/local/var/log/rabbitmq/rabbit@localhost-sasl.log
##########
Starting broker...
completed with 10 plugins.
Celery Worker
-------------- celery@Ajr v4.1.0 (latentcall)
---- **** -----
--- * *** * -- Darwin-16.6.0-x86_64-i386-64bit 2017-08-04 15:01:56
-- * - **** ---
- ** ---------- [config]
- ** ---------- .> app: shop:0x103ee29b0
- ** ---------- .> transport: amqp://guest:**@localhost:5672//
- ** ---------- .> results:
- *** --- * --- .> concurrency: 4 (prefork)
-- ******* ---- .> task events: OFF (enable -E to monitor tasks in this worker)
--- ***** -----
-------------- [queues]
.> celery exchange=celery(direct) key=celery
[tasks]
. apps.orders.tasks.send_order_email
[2017-08-04 15:01:56,693: INFO/MainProcess] Connected to amqp://guest:**@127.0.0.1:5672//
[2017-08-04 15:01:56,712: INFO/MainProcess] mingle: searching for neighbors
[2017-08-04 15:01:57,750: INFO/MainProcess] mingle: all alone
[2017-08-04 15:01:57,779: WARNING/MainProcess] /Users/dikiigr/MEGA/Dev/Work/PosudaHome/venv/lib/python3.5/site-packages/celery/fixups/django.py:202: UserWarning: Using settings.DEBUG leads to a memory leak, never use this setting in production environments!
warnings.warn('Using settings.DEBUG leads to a memory leak, never '
[2017-08-04 15:01:57,779: INFO/MainProcess] celery@Ajr ready.
Тестирую задачу через Shell:
>>> from apps.orders.tasks import send_order_email
>>> send_order_email(20)
Но в воркере нет никакой инфы о задаче, сама задача выполняется но синхронно. Запускал Flower, но результат такой же (задачи не выполняются асинхронно)