Note that there are some explanatory texts on larger screens.

plurals
  1. PODjango and Celery: Tasks not imported
    primarykey
    data
    text
    <p>I am using Django with Celery to run two tasks in the background related to contacts/email parsing.</p> <p>Structure is:</p> <pre><code>project /api /core tasks.py settings.py </code></pre> <p>settings.py file contains:</p> <pre><code>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', ) </code></pre> <p>tasks.py contains:</p> <pre><code>from celery.task import Task from celery.registry import tasks class ParseEmails(Task): #... class ImportGMailContactsFromGoogleAccount(Task): #... tasks.register(ParseEmails) tasks.register(ImportGMailContactsFromGoogleAccount) </code></pre> <p>Also, added in wsgi.py</p> <pre><code>os.environ["CELERY_LOADER"] = "django" </code></pre> <p>Now, I have this app hosted on a WebFactional server. On my localhost this runs fine, but on the WebFaction server, where the Django app is deployed on a Apache server, I get:</p> <pre><code>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's imported. </code></pre> <p>But the tasks show up as registered. If I run</p> <pre><code>python2.7 manage.py celeryd -l info </code></pre> <p>I obtain:</p> <pre><code> -------------- 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 </code></pre> <p>I thought it could be a relative import error, but I assumed the changes in settings.py and wsgi.py would prevent that.</p> <p>I am thinking the multiple Python version supported by WebFactional could have to do with this, however I installed all the libraries for Python 2.7 and I am also running Django for 2.7, so there should be no problem with that.</p> <p>Running in localhost using celeryd -l info the Tasks also show up in the list when I start the worker but it doesn't output the error when I call the task - it runs perfectly.</p> <p>Thank you</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload