Reputation: 16627
What would be the best way to run Celery tasks only during a specified time range (let's say only at night from 10 pm to 8 am)? No new tasks should be run outside of that time range (it's a must). A possible option I can think of would be to check the time at the beginning of the task and if not in the range raise a self.retry
with a provided eta
to re-schedule it at another time.
Is this the best way to do it or are there better options?
Upvotes: 1
Views: 215
Reputation: 19787
Celery does not provide that feature out-of-box. I think your plan is a good one (to test whether task is executing at the right time and if not re-schedule itself).
Upvotes: 1