Explorar o código

Beat: ScheduleEntry._default_now added to override the default value of last_run_at

Ask Solem %!s(int64=14) %!d(string=hai) anos
pai
achega
d41db95986
Modificáronse 1 ficheiros con 4 adicións e 1 borrados
  1. 4 1
      celery/beat.py

+ 4 - 1
celery/beat.py

@@ -73,9 +73,12 @@ class ScheduleEntry(object):
         self.args = args
         self.kwargs = kwargs
         self.options = options
-        self.last_run_at = last_run_at or datetime.now()
+        self.last_run_at = last_run_at or self._default_now()
         self.total_run_count = total_run_count or 0
 
+    def _default_now(self):
+        return datetime.now()
+
     def next(self, last_run_at=None):
         """Returns a new instance of the same class, but with
         its date and count fields updated."""