torchbox / wagtail-template

A Django template for starting new Wagtail projects with Vagrant. NO LONGER MAINTANED
19 stars 8 forks source link

Celery BROKER_URL is not recognised #24

Closed balazs-endresz closed 9 years ago

balazs-endresz commented 9 years ago

Django is trying to connect to rabbitmq on port 5672, which is the default setting for celery. I think we're missing the following from project_name/project_name/__init__.py:

from __future__ import absolute_import

# This will make sure the app is always imported when
# Django starts so that shared_task will use this app.
from .celery import app as celery_app

http://celery.readthedocs.org/en/latest/django/first-steps-with-django.html

I've just tried this and now I don't get a connection refused error when queueing a delayed task.

kaedroho commented 9 years ago

Thanks for spotting, could you submit a pull request?

balazs-endresz commented 9 years ago

Sure, I was about to, but we should probably make a decision about this first: https://torchbox.codebasehq.com/projects/sysadmin/tickets/2072

zerolab commented 9 years ago

I may be reading it wrong, but the import in __init__.py is there for @shared_task to work. Still worth fixing this as I missed it in #23

Considering that django-celery is at 3.1.16 and celery incorporates it as of 3.1.17, I vote for the latter.

D

balazs-endresz commented 9 years ago

@zerolab Well, I'm not sure, I haven't used this version of celery before, but this seems to be required for any task not just shared ones. Otherwise django is not aware which celery app to use.

balazs-endresz commented 9 years ago

Or, I guess this wouldn't be required if we used

from project_name.celery import app
@app.task
def mytask(): ...

instead of

from celery.decorators import task
@task
def mytask(): ...
zerolab commented 9 years ago

25 was merged. closing.