liuliqiang / redisbeat

celery redis scheduler, dynamic add/modify/delete task from celery.
MIT License
178 stars 44 forks source link

How to setup an Timzone properly? #33

Closed arbazkiraak closed 4 years ago

arbazkiraak commented 4 years ago
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'Asia/Kolkata'
USE_I18N = True
USE_L10N = True
USE_TZ = True

CELERY_BROKER_URL = 'redis://localhost:6379'
CELERY_RESULT_BACKEND =  CELERY_BROKER_URL
CELERY_ACCEPT_CONTENT = ['json']
CELERY_TASK_SERIALIZER = 'json'
CELERY_RESULT_SERIALIZER = 'json'
CELERY_REDBEAT_REDIS_URL = 'redis://localhost:6379/1'
CELERY_ENABLED_UTC = False
CELERY_TIMEZONE = 'Asia/Kolkata'
CELERYBEAT_MAX_LOOP_INTERVAL = 1  # redbeat likes fast loops ## keep it 5
CELERYBEAT_SCHEDULER = 'redbeat.RedBeatScheduler'
CELERY_TASK_SOFT_TIME_LIMIT = 14400
CELERY_TASK_TIME_LIMIT = 14420
interval_c = celery.schedules.schedule(run_every=20)  # seconds
entry = RedBeatSchedulerEntry('demo_task','mainapp.tasks.Demo_Task_Run', interval_c, args=["arbaz"],options={'queue':'mainqueue'},app=app)
entry.save()
print(entry.key)

As soon as I run the scheduler task gets executed for once only and it won't repeat, this behavior is applicable on setting a CELERY_TIMEZONE