Skip to content

Commit

Permalink
Tolerate more on intensive fire
Browse files Browse the repository at this point in the history
  • Loading branch information
polyrabbit committed Feb 21, 2024
1 parent 7faf886 commit 3907a4f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions WeCron/remind/models/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


class RemindScheduler(BackgroundScheduler):
misfire_grace_time = 60
misfire_grace_time = 5 * 60
MAX_WAIT_TIME = 60*60 # wake up every hour

def _process_jobs(self):
Expand All @@ -29,7 +29,7 @@ def _process_jobs(self):
# Statically store the select result, in case of modifying the result in selection,
# which will results in a infinite selection.
remind_list = list(Remind.objects.select_for_update().filter(
done=False, notify_time__range=(now - grace_time, now)).all())
done=False, notify_time__range=(now - grace_time, now)).order_by('notify_time').all())
for rem in remind_list:
try:
rem.notify_users()
Expand Down
5 changes: 4 additions & 1 deletion WeCron/wxhook/todo_parser/local_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import re
import logging
import random
from dateutil.relativedelta import relativedelta
from django.utils import timezone
from remind.models import Remind
Expand Down Expand Up @@ -439,7 +440,9 @@ def consume_day_period(self):
# 两天后下午三点
if not has_hour and not self.consume_hour():
self.time_fields['hour'] = hour
self.time_fields['minute'] = DEFAULT_MINUTE
# self.time_fields['minute'] = DEFAULT_MINUTE
# In case of intensive fire at 8:00 a.m.
self.time_fields['minute'] = random.randint(0, 3)
return self.get_index() - beginning

def consume_weekday_period(self):
Expand Down

0 comments on commit 3907a4f

Please sign in to comment.