I am using Django with Celery to run two tasks in the background related to parsing / email.
Structure:
project /api /core tasks.py settings.py
File
settings.py contains:
BROKER_URL = 'django://' BROKER_BACKEND = "djkombu.transport.DatabaseTransport" #celery BROKER_HOST = "localhost" BROKER_PORT = 5672 BROKER_USER = "guest" BROKER_PASSWORD = "guest" BROKER_VHOST = "/" sys.path.append(os.path.dirname(os.path.basename(__file__))) CELERY_IMPORTS = ['project.core.tasks'] import djcelery djcelery.setup_loader() # .... INSTALLED_APPS = ( #... 'kombu.transport.django', 'djcelery', )
tasks.py contains:
from celery.task import Task from celery.registry import tasks class ParseEmails(Task):
Also added to wsgi.py
os.environ["CELERY_LOADER"] = "django"
Now I have this application hosted on a WebFactional server. On my localhost, this works fine, but on the WebFaction server, where the Django application is deployed to the Apache server, I get:
2013-01-23 17:25:00,067: ERROR/MainProcess] Task project.core.tasks.ImportGMailContactsFromGoogleAccount[df84e03f-9d22-44ed-a305-24c20407f87c] raised exception: Task of kind 'project.core.tasks.ImportGMailContactsFromGoogleAccount' is not registered, please make sure it imported.
But tasks are displayed as registered. If I run
python2.7 manage.py celeryd -l info
I get:
-------------- celery@web303.webfaction.com v3.0.13 (Chiastic Slide) ---- **** ----- --- * *** * -- [Configuration] -- * - **** --- . broker: django://localhost// - ** ---------- . app: default:0x1e55350 (djcelery.loaders.DjangoLoader) - ** ---------- . concurrency: 8 (processes) - ** ---------- . events: OFF (enable -E to monitor this worker) - ** ---------- - *** --- * --- [Queues] -- ******* ---- . celery: exchange:celery(direct) binding:celery --- ***** ----- [Tasks] . project.core.tasks.ImportGMailContactsFromGoogleAccount . project.core.tasks.ParseEmails
I thought it might be a relative import error, but I assumed that changes to settings.py and wsgi.py would prevent this.
I think that several versions of Python supported by WebFactional may be relevant, however, I have installed all the libraries for Python 2.7 and I am also running Django for 2.7, so there should be no problem with this.
Running in localhost using celeryd -l info Tasks also appear in the list when the worker starts, but it does not display an error when the task is called - it works fine.
thanks