Celery worker with Redis broker can't execute Django task -


i'm learning python(2.7)/django(1.5) these days via developing own reddit clone (on ubuntu 14.04 lts). i'm trying incorporate celery(3.1) redis mix, using periodically run ranking algo task (on local set up). unfortunately, can't simple task execute once! can me spot i'm doing incorrectly?

here's directory structure:

-unconnectedreddit (manage.py here)     -links (tasks.py, models.py, views.py, admin.py)     -unconnectedreddit (celery.py, __init.py___, settings.py, urls.py)         -static         -templates 

celery.py:

from __future__ import absolute_import import os celery import celery django.conf import settings  os.environ.setdefault('django_settings_module', 'unconnectedreddit.settings')  app = celery('unconnectedreddit', broker='redis://localhost:6379/0', backend='redis://localhost:6379/0',include=['unconnectedreddit.links.tasks']) app.config_from_object('django.conf:settings') app.autodiscover_tasks(lambda: settings.installed_apps)   app.conf.update(     celery_task_result_expires=3600, )  if __name__ == '__main__':     app.start() 

additions settings.py follows. note did run migrate after adding 'djcelery' installed apps:

installed_apps = ('djcelery',)  import djcelery djcelery.setup_loader()  broker_url = 'redis://localhost:6379/0'  celery_imports = ('links.tasks', )    celery_always_eager = false  celery_result_backend = 'redis://localhost:6379/0'  celery_accept_content = ['json'] celery_task_serializer = 'json' celery_result_serializer = 'json' celery_ignore_result=true  datetime import timedelta  celerybeat_schedule = {     'rank_all-every-30-seconds': {         'task': 'tasks.rank_all',         'schedule': timedelta(seconds=30),     }, }  celery_timezone = 'utc' 

__init__.py:

from __future__ import absolute_import .celery import app celery_app1 

tasks.py:

import os unconnectedreddit import celery_app1 import time links.models import link  @celery_app1.task def rank_all():     link in link.with_votes.all():         link.set_rank() #ranks interesting 'links' submitted users 

i'm running command on terminal start worker: celery -a unconnectedreddit worker -l info

the output follows:

 -------------- celery@has-virtualbox v3.1.18 (cipater) ---- **** -----  --- * ***  * -- linux-3.16.0-30-generic-x86_64-with-ubuntu-14.04-trusty -- * - **** ---  - ** ---------- [config] - ** ---------- .> app:         unconnectedreddit:0x7f938b838910 - ** ---------- .> transport:   redis://localhost:6379/0 - ** ---------- .> results:     redis://localhost:6379/0 - *** --- * --- .> concurrency: 1 (prefork) -- ******* ----  --- ***** ----- [queues]  -------------- .> celery           exchange=celery(direct) key=celery   [tasks]   . links.tasks.rank_all  [2015-06-04 12:01:17,083: info/mainprocess] connected redis://localhost:6379/0 [2015-06-04 12:01:17,098: info/mainprocess] mingle: searching neighbors [2015-06-04 12:01:18,107: info/mainprocess] mingle: alone /home/has/.virtualenvs/unconnectedreddit/local/lib/python2.7/site-packages/celery/fixups/django.py:265: userwarning: using settings.debug leads memory leak, never use setting in production environments!   warnings.warn('using settings.debug leads memory leak, never '  [2015-06-04 12:01:18,136: warning/mainprocess] /home/has/.virtualenvs/unconnectedreddit/local/lib/python2.7/site-packages/celery/fixups/django.py:265: userwarning: using settings.debug leads memory leak, never use setting in production environments!   warnings.warn('using settings.debug leads memory leak, never '  [2015-06-04 12:01:18,137: warning/mainprocess] celery@has-virtualbox ready. 

that's it. had set out periodically run task after every 30 seconds (see celerybeat_schedule). code doesn't result in executing once - rankings on reddit clone don't change @ all. can expert point out i'm missing in set up?

wrong task name. got fixed changing task decorator @celery_app1.task(name='tasks.rank_all') , tweaking beat schedule include correct name:

celerybeat_schedule = {     'tasks.rank_all': {         'task': 'tasks.rank_all',         'schedule': timedelta(seconds=30),     }, } 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -