This is my periodic task:
from celery.task import PeriodicTask
from celery.registry import tasks
from datetime import timedelta
from datetime import datetime
class MyTask(PeriodicTask):
run_every = timedelta(minutes=1)
def run(self, **kwargs):
self.get_logger().info("Time now: " + datetime.now())
print("Time now: " + datetime.now())
tasks.register(MyTask)
I started my django server at python manage.py runserver and also started celery with python manage.py celeryd -B.
Still nothing gets printed on the command prompt though according to the code, the time should have been printed.
Any idea what's going wrong here? Seems quite straight forward.