Django Celery计划任务崩溃



我试图在Heroku上托管的Django项目上运行一个计划任务,但我的任务一直崩溃,我不知道如何解决这个问题。以下是我在错误日志中得到的错误消息。我的设置中有.py,我的时区设置为"America/New_York",我甚至尝试在celery.py中添加时区,使其保持不变,以尝试排除故障,但对其没有影响。我感谢您的帮助。感谢

完整追溯

2020-09-29T14:42:42.978802+00:00 app[beat.1]: [2020-09-29 10:42:42,978: INFO/MainProcess] DatabaseScheduler: Schedule changed.
2020-09-29T14:42:42.978947+00:00 app[beat.1]: [2020-09-29 10:42:42,978: INFO/MainProcess] Writing entries...
2020-09-29T14:42:43.007143+00:00 app[beat.1]: [2020-09-29 10:42:43,006: INFO/MainProcess] Writing entries...
2020-09-29T14:42:43.009099+00:00 app[beat.1]: [2020-09-29 10:42:43,007: CRITICAL/MainProcess] beat raised exception <class 'TypeError'>: TypeError("can't compare offset-naive and offset-aware datetimes",)
2020-09-29T14:42:43.009100+00:00 app[beat.1]: Traceback (most recent call last):
2020-09-29T14:42:43.009101+00:00 app[beat.1]: File "/app/.heroku/python/lib/python3.6/site-packages/celery/apps/beat.py", line 109, in start_scheduler
2020-09-29T14:42:43.009102+00:00 app[beat.1]: service.start()
2020-09-29T14:42:43.009103+00:00 app[beat.1]: File "/app/.heroku/python/lib/python3.6/site-packages/celery/beat.py", line 631, in start
2020-09-29T14:42:43.009103+00:00 app[beat.1]: interval = self.scheduler.tick()
2020-09-29T14:42:43.009104+00:00 app[beat.1]: File "/app/.heroku/python/lib/python3.6/site-packages/celery/beat.py", line 329, in tick
2020-09-29T14:42:43.009104+00:00 app[beat.1]: self.populate_heap()
2020-09-29T14:42:43.009105+00:00 app[beat.1]: File "/app/.heroku/python/lib/python3.6/site-packages/celery/beat.py", line 303, in populate_heap
2020-09-29T14:42:43.009105+00:00 app[beat.1]: is_due, next_call_delay = entry.is_due()
2020-09-29T14:42:43.009106+00:00 app[beat.1]: File "/app/.heroku/python/lib/python3.6/site-packages/django_celery_beat/schedulers.py", line 116, in is_due
2020-09-29T14:42:43.009106+00:00 app[beat.1]: if now < self.model.start_time:
2020-09-29T14:42:43.009238+00:00 app[beat.1]: TypeError: can't compare offset-naive and offset-aware datetimes
2020-09-29T14:42:43.009823+00:00 app[beat.1]: [2020-09-29 10:42:43,009: WARNING/MainProcess] Traceback (most recent call last):
2020-09-29T14:42:43.015389+00:00 app[beat.1]: [2020-09-29 10:42:43,015: WARNING/MainProcess] File "/app/.heroku/python/bin/celery", line 8, in <module>
2020-09-29T14:42:43.015917+00:00 app[beat.1]: [2020-09-29 10:42:43,015: WARNING/MainProcess] sys.exit(main())
2020-09-29T14:42:43.016172+00:00 app[beat.1]: [2020-09-29 10:42:43,016: WARNING/MainProcess] File "/app/.heroku/python/lib/python3.6/site-packages/celery/__main__.py", line 16, in main
2020-09-29T14:42:43.016596+00:00 app[beat.1]: [2020-09-29 10:42:43,016: WARNING/MainProcess] _main()
2020-09-29T14:42:43.016852+00:00 app[beat.1]: [2020-09-29 10:42:43,016: WARNING/MainProcess] File "/app/.heroku/python/lib/python3.6/site-packages/celery/bin/celery.py", line 322, in main
2020-09-29T14:42:43.017500+00:00 app[beat.1]: [2020-09-29 10:42:43,017: WARNING/MainProcess] cmd.execute_from_commandline(argv)
2020-09-29T14:42:43.017744+00:00 app[beat.1]: [2020-09-29 10:42:43,017: WARNING/MainProcess] File "/app/.heroku/python/lib/python3.6/site-packages/celery/bin/celery.py", line 499, in execute_from_commandline
2020-09-29T14:42:43.018496+00:00 app[beat.1]: [2020-09-29 10:42:43,018: WARNING/MainProcess] super(CeleryCommand, self).execute_from_commandline(argv)))
2020-09-29T14:42:43.018734+00:00 app[beat.1]: [2020-09-29 10:42:43,018: WARNING/MainProcess] File "/app/.heroku/python/lib/python3.6/site-packages/celery/bin/base.py", line 305, in execute_from_commandline
2020-09-29T14:42:43.019331+00:00 app[beat.1]: [2020-09-29 10:42:43,019: WARNING/MainProcess] return self.handle_argv(self.prog_name, argv[1:])
2020-09-29T14:42:43.019575+00:00 app[beat.1]: [2020-09-29 10:42:43,019: WARNING/MainProcess] File "/app/.heroku/python/lib/python3.6/site-packages/celery/bin/celery.py", line 491, in handle_argv
2020-09-29T14:42:43.020344+00:00 app[beat.1]: [2020-09-29 10:42:43,020: WARNING/MainProcess] return self.execute(command, argv)
2020-09-29T14:42:43.020591+00:00 app[beat.1]: [2020-09-29 10:42:43,020: WARNING/MainProcess] File "/app/.heroku/python/lib/python3.6/site-packages/celery/bin/celery.py", line 419, in execute
2020-09-29T14:42:43.021307+00:00 app[beat.1]: [2020-09-29 10:42:43,021: WARNING/MainProcess] ).run_from_argv(self.prog_name, argv[1:], command=argv[0])
2020-09-29T14:42:43.021544+00:00 app[beat.1]: [2020-09-29 10:42:43,021: WARNING/MainProcess] File "/app/.heroku/python/lib/python3.6/site-packages/celery/bin/base.py", line 309, in run_from_argv
2020-09-29T14:42:43.022129+00:00 app[beat.1]: [2020-09-29 10:42:43,022: WARNING/MainProcess] sys.argv if argv is None else argv, command)
2020-09-29T14:42:43.022361+00:00 app[beat.1]: [2020-09-29 10:42:43,022: WARNING/MainProcess] File "/app/.heroku/python/lib/python3.6/site-packages/celery/bin/base.py", line 393, in handle_argv
2020-09-29T14:42:43.022958+00:00 app[beat.1]: [2020-09-29 10:42:43,022: WARNING/MainProcess] return self(*args, **options)
2020-09-29T14:42:43.023195+00:00 app[beat.1]: [2020-09-29 10:42:43,023: WARNING/MainProcess] File "/app/.heroku/python/lib/python3.6/site-packages/celery/bin/base.py", line 253, in __call__
2020-09-29T14:42:43.023702+00:00 app[beat.1]: [2020-09-29 10:42:43,023: WARNING/MainProcess] ret = self.run(*args, **kwargs)
2020-09-29T14:42:43.023942+00:00 app[beat.1]: [2020-09-29 10:42:43,023: WARNING/MainProcess] File "/app/.heroku/python/lib/python3.6/site-packages/celery/bin/beat.py", line 109, in run
2020-09-29T14:42:43.024413+00:00 app[beat.1]: [2020-09-29 10:42:43,024: WARNING/MainProcess] return beat().run()
2020-09-29T14:42:43.024637+00:00 app[beat.1]: [2020-09-29 10:42:43,024: WARNING/MainProcess] File "/app/.heroku/python/lib/python3.6/site-packages/celery/apps/beat.py", line 81, in run
2020-09-29T14:42:43.025072+00:00 app[beat.1]: [2020-09-29 10:42:43,024: WARNING/MainProcess] self.start_scheduler()
2020-09-29T14:42:43.025311+00:00 app[beat.1]: [2020-09-29 10:42:43,025: WARNING/MainProcess] File "/app/.heroku/python/lib/python3.6/site-packages/celery/apps/beat.py", line 109, in start_scheduler
2020-09-29T14:42:43.025757+00:00 app[beat.1]: [2020-09-29 10:42:43,025: WARNING/MainProcess] service.start()
2020-09-29T14:42:43.025990+00:00 app[beat.1]: [2020-09-29 10:42:43,025: WARNING/MainProcess] File "/app/.heroku/python/lib/python3.6/site-packages/celery/beat.py", line 631, in start
2020-09-29T14:42:43.027391+00:00 app[beat.1]: [2020-09-29 10:42:43,027: WARNING/MainProcess] interval = self.scheduler.tick()
2020-09-29T14:42:43.027632+00:00 app[beat.1]: [2020-09-29 10:42:43,027: WARNING/MainProcess] File "/app/.heroku/python/lib/python3.6/site-packages/celery/beat.py", line 329, in tick
2020-09-29T14:42:43.028227+00:00 app[beat.1]: [2020-09-29 10:42:43,028: WARNING/MainProcess] self.populate_heap()
2020-09-29T14:42:43.028462+00:00 app[beat.1]: [2020-09-29 10:42:43,028: WARNING/MainProcess] File "/app/.heroku/python/lib/python3.6/site-packages/celery/beat.py", line 303, in populate_heap
2020-09-29T14:42:43.029032+00:00 app[beat.1]: [2020-09-29 10:42:43,028: WARNING/MainProcess] is_due, next_call_delay = entry.is_due()
2020-09-29T14:42:43.029270+00:00 app[beat.1]: [2020-09-29 10:42:43,029: WARNING/MainProcess] File "/app/.heroku/python/lib/python3.6/site-packages/django_celery_beat/schedulers.py", line 116, in is_due
2020-09-29T14:42:43.029721+00:00 app[beat.1]: [2020-09-29 10:42:43,029: WARNING/MainProcess] if now < self.model.start_time:
2020-09-29T14:42:43.029975+00:00 app[beat.1]: [2020-09-29 10:42:43,029: WARNING/MainProcess] TypeError
2020-09-29T14:42:43.030203+00:00 app[beat.1]: [2020-09-29 10:42:43,030: WARNING/MainProcess] :
2020-09-29T14:42:43.030414+00:00 app[beat.1]: [2020-09-29 10:42:43,030: WARNING/MainProcess] can't compare offset-naive and offset-aware datetimes
2020-09-29T14:42:43.030780+00:00 app[beat.1]: [2020-09-29 10:42:43,030: INFO/MainProcess] Writing entries...
2020-09-29T14:42:43.031212+00:00 app[beat.1]: [2020-09-29 10:42:43,031: INFO/MainProcess] Writing entries...
2020-09-29T14:42:43.802748+00:00 heroku[beat.1]: Process exited with status 1
2020-09-29T14:42:43.935099+00:00 heroku[beat.1]: State changed from up to crashed
2020-09-29T14:42:43.937921+00:00 heroku[beat.1]: State changed from crashed to starting
2020-09-29T14:42:57.507088+00:00 heroku[beat.1]: Starting process with command `celery -A missinglink beat -l info`
2020-09-29T14:42:58.149201+00:00 heroku[beat.1]: State changed from starting to up

所以解决方案是我必须添加settings.py

#Time Zone
USE_TZ = True    <--- Added
TIME_ZONE = 'America/New_York'
Heroku on Settings and Show Variables
TZ America/New_York

相关内容

  • 没有找到相关文章

最新更新