How to solve the problem of infinite creation of scheduled tasks by django_celery_beat?

how to solve the problem of infinite creation of scheduled tasks by django_celery_beat?


CELERY_BEAT_SCHEDULER = "django_celery_beat.schedulers:DatabaseScheduler"


from __future__ import absolute_import, unicode_literals
from celery import shared_task
@shared_task
def add(x, y):
    return x + y
    
  

django-admin configure periodic tasks
clipboard.png

beat
-sharp celery -A CDNAdmin beat --loglevel=debug
celery beat v4.1.0 (latentcall) is starting.
__    -    ... __   -        _
LocalTime -> 2018-04-23 17:01:12
Configuration ->
    . broker -> redis://127.0.0.1:6379/1
    . loader -> celery.loaders.app.AppLoader
    . scheduler -> django_celery_beat.schedulers.DatabaseScheduler

    . logfile -> [stderr]@%DEBUG
    . maxinterval -> 5.00 seconds (5s)
[2018-04-23 17:01:12,014: DEBUG/MainProcess] Setting default socket timeout to 30
[2018-04-23 17:01:12,015: INFO/MainProcess] beat: Starting...
[2018-04-23 17:01:12,015: DEBUG/MainProcess] DatabaseScheduler: initial read
[2018-04-23 17:01:12,015: INFO/MainProcess] Writing entries...
[2018-04-23 17:01:12,021: DEBUG/MainProcess] DatabaseScheduler: Fetching database schedule
[2018-04-23 17:01:12,038: DEBUG/MainProcess] Current schedule:
<ModelEntry: add netcut.tasks.add(*[2, 2], **{}) <freq: 5.00 minutes>>
<ModelEntry: celery.backend_cleanup celery.backend_cleanup(*[], **{}) <crontab: 0 4 * * * (m/h/d/dM/MY)>>
[2018-04-23 17:01:12,065: DEBUG/MainProcess] beat: Ticking with max interval->5.00 seconds
[2018-04-23 17:01:12,085: INFO/MainProcess] Scheduler: Sending due task add (netcut.tasks.add)
[2018-04-23 17:01:12,114: DEBUG/MainProcess] beat: Synchronizing schedule...
[2018-04-23 17:01:12,114: INFO/MainProcess] Writing entries...
[2018-04-23 17:01:12,129: DEBUG/MainProcess] netcut.tasks.add sent. id->d2179952-9d87-4ef0-8d54-7796f9816d9a
[2018-04-23 17:01:12,131: INFO/MainProcess] Scheduler: Sending due task add (netcut.tasks.add)
[2018-04-23 17:01:12,133: DEBUG/MainProcess] netcut.tasks.add sent. id->d8651734-6481-4897-95f6-33da66df6de3
[2018-04-23 17:01:12,136: INFO/MainProcess] Scheduler: Sending due task add (netcut.tasks.add)
[2018-04-23 17:01:12,138: DEBUG/MainProcess] netcut.tasks.add sent. id->a6f5407a-f7d9-4319-a9ec-6d5dc207b217
[2018-04-23 17:01:12,140: INFO/MainProcess] Scheduler: Sending due task add (netcut.tasks.add)
[2018-04-23 17:01:12,142: DEBUG/MainProcess] netcut.tasks.add sent. id->85d71d15-8be4-4582-b80b-afa396159cba
[2018-04-23 17:01:12,144: INFO/MainProcess] Scheduler: Sending due task add (netcut.tasks.add)
[2018-04-23 17:01:12,146: DEBUG/MainProcess] netcut.tasks.add sent. id->d099f9ba-6fc3-4230-9b1c-2300ac43a315
[2018-04-23 17:01:12,148: INFO/MainProcess] Scheduler: Sending due task add (netcut.tasks.add)
[2018-04-23 17:01:12,150: DEBUG/MainProcess] netcut.tasks.add sent. id->49d21492-6547-440c-89bb-1ee7f541edfc
[2018-04-23 17:01:12,152: INFO/MainProcess] Scheduler: Sending due task add (netcut.tasks.add)
[2018-04-23 17:01:12,155: DEBUG/MainProcess] netcut.tasks.add sent. id->3fe360c0-d3dc-47d8-b0a3-4ce197f545db
[2018-04-23 17:01:12,157: INFO/MainProcess] Scheduler: Sending due task add (netcut.tasks.add)
[2018-04-23 17:01:12,159: DEBUG/MainProcess] netcut.tasks.add sent. id->92e38cfb-2838-4d56-9dc7-efaa6635ce05
[2018-04-23 17:01:12,162: INFO/MainProcess] Scheduler: Sending due task add (netcut.tasks.add)
[2018-04-23 17:01:12,164: DEBUG/MainProcess] netcut.tasks.add sent. id->8986f037-e7c0-4386-90d5-1ad8c685befc
[2018-04-23 17:01:12,167: INFO/MainProcess] Scheduler: Sending due task add (netcut.tasks.add)
[2018-04-23 17:01:12,169: DEBUG/MainProcess] netcut.tasks.add sent. id->4ccc0c70-d7b0-4153-9c1b-a399dc8a9402
[2018-04-23 17:01:12,171: INFO/MainProcess] Scheduler: Sending due task add (netcut.tasks.add)
Mar.05,2021

found the problem, which has something to do with the celery time zone.
setting adds the following configuration

CELERY_ENABLE_UTC = False

Mom has been messing with me all night until I try it remotely when I get home


I would like to ask, what is the reason why the write task through the interface is not executed after my beat is started?

Menu