0

Hi I have added a new app called "schedule_stop" and registered the app in settings also.

Now added a new file called tasks.py and following is the content of the file,

  from celery.task.schedules import crontab
  from celery.decorators import periodic_task
  from django.conf import settings
  import logging

  logger = logging.getLogger('app.main')

  @periodic_task(run_every=crontab(minute='*/1'), options={'queue':settings.APP_CORE_QUEUE})
  def delete_inactive_task():
        logger.info('log value')

value of settings.APP_CORE_QUEUE = app_core_queue

required celery process are running as below,

ubuntu    5711  0.0  1.0 188564 41172 pts/0    S+   10:28   0:00 /home/ubuntu/devbuild/venv/bin/python /home/ubuntu/devbuild/venv/octopus/../bin/django-admin celery -A app beat
ubuntu    5712  0.0  1.2 218344 52428 pts/0    S+   10:28   0:00 /home/ubuntu/devbuild/venv/bin/python /home/ubuntu/devbuild/venv/app/../bin/django-admin celery worker -Q app_core_queue
ubuntu    5733  0.0  1.1 216484 47192 pts/0    S+   10:28   0:00 /home/ubuntu/devbuild/venv/bin/python /home/ubuntu/devbuild/venv/app/../bin/django-admin celery worker -Q app_core_queue

But still above function delete_intractive_task() is nog getting execute for every one minute. How to debug what is the issue ?

tasks.py file is not even getting executed during the start of the application, even if there is any syntax error in this tasks.py file its not giving any error

Below is the file structure,

schedule_stop/
   ├── api.py
   ├── __init__.py
   ├── __init__.pyc
   ├── tasks.py
   ├── urls.py
   └── views.py
Naggappan Ramukannan
  • 2,564
  • 9
  • 36
  • 59

1 Answers1

0

You need a file called celery.py in the main app of your project, which imports celery and registers the tasks that need to be done (usually using the autodiscover_tasks of a Celery object). See here:

http://docs.celeryproject.org/en/latest/django/first-steps-with-django.html

ubadub
  • 3,571
  • 21
  • 32