Procházet zdrojové kódy

celerybeat: Remaining now works better, PeriodicTask.is_due now returns (is_due, next_time_to_run) instead, where next_time_to_run is in seconds.

Ask Solem před 15 roky
rodič
revize
498b83c74e
1 změnil soubory, kde provedl 5 přidání a 4 odebrání
  1. 5 4
      celery/task/base.py

+ 5 - 4
celery/task/base.py

@@ -587,14 +587,15 @@ class PeriodicTask(Task):
 
     def remaining_estimate(self, last_run_at):
         rem = (last_run_at + self.run_every) - datetime.now()
+        now = False
         if rem.days == -1:
-            return 0
-        return rem.seconds + (rem.microseconds / 10e5)
+            now = True
+            rem = self.run_every
+        return now, rem.seconds + (rem.microseconds / 10e5)
 
     def is_due(self, last_run_at):
         """Returns ``True`` if the task is due.
 
         You can override this to decide the interval at runtime.
         """
-        remaining = self.remaining_estimate(last_run_at)
-        return not remaining, remaining
+        return self.remaining_estimate(last_run_at)