我有一个根据docs设置芹菜的PeriodicTask:
from celery.task import PeriodicTask
from datetime import timedelta
class PingTask(PeriodicTask):
run_every = timedelta(seconds=5)
def run(self, **kwargs):
print("PING!")
当我运行该应用程序时,显然已安排了定期任务,但是为什么不将其打印到控制台?如何确认预定任务确实在运行?
web_1 | Performing system checks...
web_1 |
web_1 | System check identified no issues (0 silenced).
web_1 | July 27, 2019 - 10:37:50
web_1 | Django version 2.0.13, using settings 'proj.settings'
web_1 | Starting development server at http://0.0.0.0:8000/
web_1 | Quit the server with CONTROL-C.
celery_1 | [2019-07-27 10:37:53,311: INFO/Beat] Scheduler: Sending due task notifications.tasks.PingTask (notifications.tasks.PingTask)
celery_1 | [2019-07-27 10:37:58,288: INFO/Beat] Scheduler: Sending due task notifications.tasks.PingTask (notifications.tasks.PingTask)
celery_1 | [2019-07-27 10:38:03,288: INFO/Beat] Scheduler: Sending due task notifications.tasks.PingTask (notifications.tasks.PingTask)