Skip to content

Commit

Permalink
Made ScheduleEntry._default_now method public
Browse files Browse the repository at this point in the history
  • Loading branch information
mkai authored and georgepsarakis committed Sep 3, 2017
1 parent c816114 commit 4f77d42
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions celery/beat.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,17 @@ def __init__(self, name=None, task=None, last_run_at=None,
self.kwargs = kwargs
self.options = options
self.schedule = maybe_schedule(schedule, relative, app=self.app)
self.last_run_at = last_run_at or self._default_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):
def default_now(self):
return self.schedule.now() if self.schedule else self.app.now()

def _next_instance(self, last_run_at=None):
"""Return new instance, with date and count fields updated."""
return self.__class__(**dict(
self,
last_run_at=last_run_at or self._default_now(),
last_run_at=last_run_at or self.default_now(),
total_run_count=self.total_run_count + 1,
))
__next__ = next = _next_instance # for 2to3
Expand Down Expand Up @@ -237,7 +237,7 @@ def is_due(self, entry):
def _when(self, entry, next_time_to_run, mktime=time.mktime):
adjust = self.adjust

return (mktime(entry._default_now().timetuple()) +
return (mktime(entry.default_now().timetuple()) +
(adjust(next_time_to_run) or 0))

def populate_heap(self, event_t=event_t, heapify=heapq.heapify):
Expand Down

0 comments on commit 4f77d42

Please sign in to comment.