Im going over this list here but i cant get it working :
http://docs.celeryproject.org/en/latest/django/first-steps-with-django.html
So what i did was: 1) downloaded celery modules and added them to my manage.py and wsgi.py:
# -*- coding: utf-8 -*-
#!/usr/bin/env python
import os, sys
from ConfigParser import RawConfigParser
config = RawConfigParser()
abspath = os.path.abspath(os.path.dirname(__file__))
config.read(abspath+'/subfolder/settings.ini')
homedir = config.get('paths', 'libspath')
projectspath = config.get('paths', 'projectspath')
path = [
'/Django-1.4.5/',
'/South-0.7.6',
'/python-openid-master',#07.05.2013 checkout from https://github.com/openid/python-openid
'/mbi-django-rosetta-eca151e',
'/phonenumbers-5.2b1',
'/django-phonenumber-field-develop',
'/django-openid-auth-0.5',
'/celery-3.0.19',
'/django-celery-3.0.17',
'/kombu-2.5.11',
'/billiard-2.7.3.28',
'/anyjson-0.3.3',
'/amqp-1.0.12'
]
for item in path:
module = homedir+item
if module not in sys.path:
sys.path.append(module)
2) installed rabbitmq 3) set up stuff in settings.py:
INSTALLED_APPS = (
---
'djcelery',
)
and in the end:
BROKER_URL = 'amqp://guest:guest@localhost:5672/'
import djcelery
djcelery.setup_loader()
4) ran python manage.py syncdb
5) since im using mod_wsgi i also added this to my wsgi.py (in addition to code i showed earlier)
import djcelery
djcelery.setup_loader()
6) i created tasks.py in my core app:
import logging, subprocess
logger = logging.getLogger('debugger')
from django.conf import settings
from celery import task
@task
def runfunc(funcname, refno):
x = 'nothing to see here'
7) i run: python manage.py celery worker --loglevel=info and get whole bunch of stuff meaning that its all good :P.
But when i go the django view which is supposed to run the task i get:
cannot import name task
Request Method: GET
Request URL: http://localhost/url/that/triggers/task/
Django Version: 1.4.5
Exception Type: ImportError
Exception Value:
cannot import name task
Exception Location: /path/to/project/core/tasks.py in <module>, line 6
When i go to manage.py shell and type from celery import task - it works just fine. if i import the function from core.tasks, then i get exactly same error message.
Can anyone explain to me wth is up here..
Alan