Skip to content

Commit 7393599

Browse files
Override maybe maybemakeaware
1 parent e538fff commit 7393599

File tree

1 file changed

+49
-46
lines changed

1 file changed

+49
-46
lines changed

django_celery_beat/models.py

Lines changed: 49 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -111,52 +111,55 @@ def __str__(self):
111111

112112
class TZNaiveSchedule(schedules.schedule):
113113

114-
def remaining_estimate(self, last_run_at):
115-
return remaining(
116-
last_run_at,
117-
self.run_every,
118-
self.now(),
119-
self.relative
120-
)
121-
122-
def is_due(self, last_run_at):
123-
"""Return tuple of ``(is_due, next_time_to_check)``.
124-
125-
Notes:
126-
- next time to check is in seconds.
127-
128-
- ``(True, 20)``, means the task should be run now, and the next
129-
time to check is in 20 seconds.
130-
131-
- ``(False, 12.3)``, means the task is not due, but that the
132-
scheduler should check again in 12.3 seconds.
133-
134-
This is like `schedules.schedule` except it does not turn `last_run_at`
135-
into a tzaware object.
136-
137-
The next time to check is used to save energy/CPU cycles,
138-
it does not need to be accurate but will influence the precision
139-
of your schedule. You must also keep in mind
140-
the value of :setting:`beat_max_loop_interval`,
141-
that decides the maximum number of seconds the scheduler can
142-
sleep between re-checking the periodic task intervals. So if you
143-
have a task that changes schedule at run-time then your next_run_at
144-
check will decide how long it will take before a change to the
145-
schedule takes effect. The max loop interval takes precedence
146-
over the next check at value returned.
147-
148-
.. admonition:: Scheduler max interval variance
149-
150-
The default max loop interval may vary for different schedulers.
151-
For the default scheduler the value is 5 minutes, but for example
152-
the :pypi:`django-celery-beat` database scheduler the value
153-
is 5 seconds.
154-
"""
155-
rem_delta = self.remaining_estimate(last_run_at)
156-
remaining_s = max(rem_delta.total_seconds(), 0)
157-
if remaining_s == 0:
158-
return schedules.schedstate(is_due=True, next=self.seconds)
159-
return schedules.schedstate(is_due=False, next=remaining_s)
114+
def maybe_make_aware(self, dt):
115+
return dt
116+
117+
# def remaining_estimate(self, last_run_at):
118+
# return remaining(
119+
# last_run_at,
120+
# self.run_every,
121+
# self.now(),
122+
# self.relative
123+
# )
124+
125+
# def is_due(self, last_run_at):
126+
# """Return tuple of ``(is_due, next_time_to_check)``.
127+
128+
# Notes:
129+
# - next time to check is in seconds.
130+
131+
# - ``(True, 20)``, means the task should be run now, and the next
132+
# time to check is in 20 seconds.
133+
134+
# - ``(False, 12.3)``, means the task is not due, but that the
135+
# scheduler should check again in 12.3 seconds.
136+
137+
# This is like `schedules.schedule` except it does not turn `last_run_at`
138+
# into a tzaware object.
139+
140+
# The next time to check is used to save energy/CPU cycles,
141+
# it does not need to be accurate but will influence the precision
142+
# of your schedule. You must also keep in mind
143+
# the value of :setting:`beat_max_loop_interval`,
144+
# that decides the maximum number of seconds the scheduler can
145+
# sleep between re-checking the periodic task intervals. So if you
146+
# have a task that changes schedule at run-time then your next_run_at
147+
# check will decide how long it will take before a change to the
148+
# schedule takes effect. The max loop interval takes precedence
149+
# over the next check at value returned.
150+
151+
# .. admonition:: Scheduler max interval variance
152+
153+
# The default max loop interval may vary for different schedulers.
154+
# For the default scheduler the value is 5 minutes, but for example
155+
# the :pypi:`django-celery-beat` database scheduler the value
156+
# is 5 seconds.
157+
# """
158+
# rem_delta = self.remaining_estimate(last_run_at)
159+
# remaining_s = max(rem_delta.total_seconds(), 0)
160+
# if remaining_s == 0:
161+
# return schedules.schedstate(is_due=True, next=self.seconds)
162+
# return schedules.schedstate(is_due=False, next=remaining_s)
160163

161164

162165
@python_2_unicode_compatible

0 commit comments

Comments
 (0)