Explorar o código

Have schedule range wrap around max_ if to < fr, ie. (months): 11-1 => [11, 12, 1]

Loren Abrams %!s(int64=12) %!d(string=hai) anos
pai
achega
b6ec1f9354
Modificáronse 1 ficheiros con 8 adicións e 4 borrados
  1. 8 4
      celery/schedules.py

+ 8 - 4
celery/schedules.py

@@ -206,7 +206,9 @@ class crontab_parser(object):
         fr = self._expand_number(toks[0])
         if len(toks) > 1:
             to = self._expand_number(toks[1])
-            return range(fr, min(to + 1, self.max_ + 1))
+            if to < fr:  # Wrap around max_ if necessary
+                return range(fr, self.min_ + self.max_) + range(self.min_, to + 1)
+            return range(fr, to + 1)
         return [fr]
 
     def _range_steps(self, toks):
@@ -233,12 +235,14 @@ class crontab_parser(object):
             except KeyError:
                 raise ValueError('Invalid weekday literal {0!r}.'.format(s))
 
+        max_val = self.min_ + self.max_ - 1
+        if i > max_val:
+            raise ValueError(
+                'Invalid end range: {0} > {1}.'.format(i, max_val))
         if i < self.min_:
             raise ValueError(
                 'Invalid beginning range: {0} < {1}.'.format(i, self.min_))
-        if i > self.max_:
-            raise ValueError(
-                'Invalid end range: {0} > {1}.'.format(i, self.max_))
+
         return i