votes up 2

unable to rollover, time specification is probably invalid

github stars 17847
Exception Class:

Raise code

if datedata.moy == len(months_of_year):
                        datedata.moy = 0
                        datedata.year += 1
                # Tried 2000 times, we're most likely in an infinite loop
                raise RuntimeError('unable to rollover, '
                                   'time specification is probably invalid')

        if last_run_at.month in self.month_of_year:
            datedata.dom = bisect(days_of_month,
            datedata.moy = bisect_left(months_of_year, last_run_at.month)
            datedata.dom = 0

Comment explaining raise

Tried 2000 times, we're most likely in an infinite loop

ūüôŹ Scream for help to Ukraine
Today, 14th August 2022, Russia continues bombing and firing Ukraine. Don't trust Russia, they are bombing us and brazenly lying in same time they are not doing this ūüė†, civilians and children are dying too! We are screaming and asking exactly you to help us, we want to survive, our families, children, older ones.
Please spread the information, and ask your governemnt to stop Russia by any means. We promise to work extrahard after survival to make the world safer place for all.

Ways to fix

votes up 1 votes down

The exception is thrown when dealing with the celery schedule. So that, creating a crontab with an empty list of day_of_month parameter causes an error.

A Crontab can be used as the run_every value of a periodic task entry to add crontab(5)-like scheduling.

To Reproduce an error

from celery.schedules import crontab
import datetime 

crona = crontab(minute=1,day_of_month=[])

is_due method returns (is_due, next_time_to_check).

For example: `(True, 20)`, means the task should be run now, and the next time to check is in 20 seconds

The exception is raised within function called roll_over()

def roll_over():
    for _ in range(2000):
        flag = (datedata.dom == len(days_of_month) or
                                  days_of_month[datedata.dom]) or

        if flag:
            datedata.dom = 0
            datedata.moy += 1
            if datedata.moy == len(months_of_year):
                datedata.moy = 0
                datedata.year += 1
        # Tried 2000 times, we're most likely in an infinite loop
        raise RuntimeError('unable to rollover, '
                            'time specification is probably invalid')

When empty days are passed within the loop, 2000 times flag variable is being True and loop is not breaking, That's why is code goes to else block and raise an error.

Fix Code

from celery.schedules import crontab
import datetime 

crona = crontab(minute=1,day_of_month=[2,5,6])

Sep 22, 2021 anonim answer
anonim 13.0k

Add a possible fix

Please authorize to post fix