Parcourir la source

Force ScheduleEntry to be orderable. Closes #2295

Ask Solem il y a 10 ans
Parent
commit
5972569489
1 fichiers modifiés avec 7 ajouts et 0 suppressions
  1. 7 0
      celery/beat.py

+ 7 - 0
celery/beat.py

@@ -17,6 +17,7 @@ import sys
 import traceback
 
 from collections import namedtuple
+from functools import total_ordering
 from threading import Event, Thread
 
 from billiard import ensure_multiprocessing
@@ -50,6 +51,7 @@ class SchedulingError(Exception):
     """An error occured while scheduling a task."""
 
 
+@total_ordering
 class ScheduleEntry(object):
     """An entry in the scheduler.
 
@@ -141,6 +143,11 @@ class ScheduleEntry(object):
             call=reprcall(self.task, self.args or (), self.kwargs or {}),
         )
 
+    def __lt__(self, other):
+        if isinstance(other, ScheduleEntry):
+            return id(self) < id(other)
+        return NotImplemented
+
 
 class Scheduler(object):
     """Scheduler for periodic tasks.