分析原因
-
按照以上意思,Django celerybeat在加载任务的时候遇见任务中有无法指定执行时间的任务,表示为NoneType类型。
-
错误code如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
[2018-04-20 17:38:29,294: CRITICAL /MainProcess ] beat raised exception <class 'AttributeError' >: AttributeError( "'NoneType' object has no attribute 'is_due'" ,) Traceback (most recent call last): File "/root/venv3/lib/python3.6/site-packages/celery/apps/beat.py" , line 107, in start_scheduler service.start() File "/root/venv3/lib/python3.6/site-packages/celery/beat.py" , line 537, in start interval = self.scheduler.tick() File "/root/venv3/lib/python3.6/site-packages/celery/beat.py" , line 255, in tick for e in values(self.schedule)] File "/root/venv3/lib/python3.6/site-packages/celery/beat.py" , line 255, in <listcomp> for e in values(self.schedule)] File "/root/venv3/lib/python3.6/site-packages/django_celery_beat/schedulers.py" , line 101, in is_due return self.schedule.is_due(self.last_run_at) AttributeError: 'NoneType' object has no attribute 'is_due' [2018-04-20 17:38:29,295: WARNING /MainProcess ] Traceback (most recent call last): [2018-04-20 17:38:29,295: WARNING /MainProcess ] File "/root/venv3/bin/celery" , line 11, in <module> [2018-04-20 17:38:29,295: WARNING /MainProcess ] sys. exit (main()) [2018-04-20 17:38:29,295: WARNING /MainProcess ] File "/root/venv3/lib/python3.6/site-packages/celery/__main__.py" , line 14, in main [2018-04-20 17:38:29,296: WARNING /MainProcess ] _main() [2018-04-20 17:38:29,296: WARNING /MainProcess ] File "/root/venv3/lib/python3.6/site-packages/celery/bin/celery.py" , line 326, in main [2018-04-20 17:38:29,296: WARNING /MainProcess ] cmd.execute_from_commandline(argv) [2018-04-20 17:38:29,296: WARNING /MainProcess ] File "/root/venv3/lib/python3.6/site-packages/celery/bin/celery.py" , line 488, in execute_from_commandline [2018-04-20 17:38:29,297: WARNING /MainProcess ] super(CeleryCommand, self).execute_from_commandline(argv))) [2018-04-20 17:38:29,297: WARNING /MainProcess ] File "/root/venv3/lib/python3.6/site-packages/celery/bin/base.py" , line 281, in execute_from_commandline [2018-04-20 17:38:29,297: WARNING /MainProcess ] return self.handle_argv(self.prog_name, argv[1:]) [2018-04-20 17:38:29,297: WARNING /MainProcess ] File "/root/venv3/lib/python3.6/site-packages/celery/bin/celery.py" , line 480, in handle_argv [2018-04-20 17:38:29,297: WARNING /MainProcess ] return self.execute( command , argv) [2018-04-20 17:38:29,297: WARNING /MainProcess ] File "/root/venv3/lib/python3.6/site-packages/celery/bin/celery.py" , line 412, in execute [2018-04-20 17:38:29,298: WARNING /MainProcess ] ).run_from_argv(self.prog_name, argv[1:], command =argv[0]) [2018-04-20 17:38:29,298: WARNING /MainProcess ] File "/root/venv3/lib/python3.6/site-packages/celery/bin/base.py" , line 285, in run_from_argv [2018-04-20 17:38:29,298: WARNING /MainProcess ] sys.argv if argv is None else argv, command ) [2018-04-20 17:38:29,298: WARNING /MainProcess ] File "/root/venv3/lib/python3.6/site-packages/celery/bin/base.py" , line 368, in handle_argv [2018-04-20 17:38:29,298: WARNING /MainProcess ] return self(*args, **options) [2018-04-20 17:38:29,298: WARNING /MainProcess ] File "/root/venv3/lib/python3.6/site-packages/celery/bin/base.py" , line 244, in __call__ [2018-04-20 17:38:29,299: WARNING /MainProcess ] ret = self.run(*args, **kwargs) [2018-04-20 17:38:29,299: WARNING /MainProcess ] File "/root/venv3/lib/python3.6/site-packages/celery/bin/beat.py" , line 107, in run [2018-04-20 17:38:29,299: WARNING /MainProcess ] return beat().run() [2018-04-20 17:38:29,299: WARNING /MainProcess ] File "/root/venv3/lib/python3.6/site-packages/celery/apps/beat.py" , line 79, in run [2018-04-20 17:38:29,299: WARNING /MainProcess ] self.start_scheduler() [2018-04-20 17:38:29,299: WARNING /MainProcess ] File "/root/venv3/lib/python3.6/site-packages/celery/apps/beat.py" , line 107, in start_scheduler [2018-04-20 17:38:29,299: WARNING /MainProcess ] service.start() [2018-04-20 17:38:29,300: WARNING /MainProcess ] File "/root/venv3/lib/python3.6/site-packages/celery/beat.py" , line 537, in start [2018-04-20 17:38:29,300: WARNING /MainProcess ] interval = self.scheduler.tick() [2018-04-20 17:38:29,300: WARNING /MainProcess ] File "/root/venv3/lib/python3.6/site-packages/celery/beat.py" , line 255, in tick [2018-04-20 17:38:29,300: WARNING /MainProcess ] for e in values(self.schedule)] [2018-04-20 17:38:29,300: WARNING /MainProcess ] File "/root/venv3/lib/python3.6/site-packages/celery/beat.py" , line 255, in <listcomp> [2018-04-20 17:38:29,300: WARNING /MainProcess ] for e in values(self.schedule)] [2018-04-20 17:38:29,301: WARNING /MainProcess ] File "/root/venv3/lib/python3.6/site-packages/django_celery_beat/schedulers.py" , line 101, in is_due [2018-04-20 17:38:29,301: WARNING /MainProcess ] return self.schedule.is_due(self.last_run_at) [2018-04-20 17:38:29,301: WARNING /MainProcess ] AttributeError [2018-04-20 17:38:29,301: WARNING /MainProcess ] : [2018-04-20 17:38:29,301: WARNING /MainProcess ] 'NoneType' object has no attribute 'is_due' |
3.第一条分析的基本正确:被指定执行的任务没有执行的时间戳导致。
4.数据库信息对比后直接确认该问题:由于该任务不想执行,所以将crontab和秒定时给去掉,所以导致以上错误。
解决方案
-
由于不想设置时间,因此采用取消激活方案。
-
数据库激活取消操作:如下图
结果
1.正常运行