Пример #1
0
    def is_due(self, last_run_at, now=None):
        """Returns tuple of two items ``(is_due, next_time_to_run)``,
        where next time to run is in seconds.

        See :meth:`unuk.contrib.tasks.models.PeriodicTask.is_due` for more information.
        """
        rem_delta = self.remaining_estimate(last_run_at, now = now)
        rem = timedelta_seconds(rem_delta)
        if rem == 0:
            return True, timedelta_seconds(self.run_every)
        return False, rem
Пример #2
0
 def scheduled_last_run_at(self):
     '''The scheduled last run datetime. This is different from :attr:`last_run_at` only when :attr:`anchor` is set.'''
     last_run_at = self.last_run_at
     anchor = self.anchor
     if last_run_at and anchor:
         run_every = self.run_every
         times = int(timedelta_seconds(last_run_at - anchor)\
                         /timedelta_seconds(run_every))
         if times:
             anchor += times*run_every
             while anchor <= last_run_at:
                 anchor += run_every
             while anchor > last_run_at:
                 anchor -= run_every
             self.schedule.anchor = anchor
         return anchor
     else:
         return last_run_at