You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Occasionally, scheduled emails and alerts won't send. From what we've observed, the scheduled task where this happens takes longer than 1 second to complete:
In that one second period, the cron_schedule_window method is unable to recognize that a daily scheduled email for 12:00PM wasn't sent.
This seems to be due to how the croniter constructs its time period to check against:
time_now = time_now.astimezone(tz)
start_at = time_now - timedelta(seconds=1)
stop_at = time_now + timedelta(seconds=window_size)
crons = croniter(cron, start_at)
for schedule in crons.all_next(datetime):
if schedule >= stop_at:
break
# convert schedule back to utc
yield schedule.astimezone(utc).replace(tzinfo=None)
In the case of a 12:00:00 PM daily job - since start_at ends up as time_now - 1 second, if the task takes longer than 1 second to run, then the time_now ends up being 12:00:01 (time_now) - 1 second = 12:00:00 instead of 12:00:00 (time_now) - 1 second = 11:59:59.
The croniter is searching for the next run time based on the specified start_at value. So, if the start_at is 12:00 and the scheduled email is supposed to run at 12:00, then croniter won't find anything since 12:00 has already passed.
For example, if the start_at is 12:00:00, it finds the next day:
from croniter import croniter
from datetime import datetime
base = datetime(2023, 7, 12, 12, 00, 00, 00)
iter = croniter('0 12 * * mon,tue,wed,thu,fri', base)
print(iter.get_next(datetime))
2023-07-13 12:00:00
Whereas if the base start datetime is 11:59:59, it picks up the cron job:
from croniter import croniter
from datetime import datetime
base = datetime(2023, 7, 12, 11, 59, 59, 00)
iter = croniter('0 12 * * mon,tue,wed,thu,fri', base) print(iter.get_next(datetime))
2023-07-12 12:00:00
Expected results
Scheduled report gets sent to the provided email - "Scheduling alert" and "Report sent to email" logs are visible.
Actual results
Scheduled report does not get sent to the provided email randomly. There are no error log indicating that there was a failure - "Scheduling alert" and "Report sent to email" messages are not in the logs
Occasionally, scheduled emails and alerts won't send. From what we've observed, the scheduled task where this happens takes longer than 1 second to complete:
In that one second period, the cron_schedule_window method is unable to recognize that a daily scheduled email for 12:00PM wasn't sent.
This seems to be due to how the croniter constructs its time period to check against:
In the case of a 12:00:00 PM daily job - since start_at ends up as time_now - 1 second, if the task takes longer than 1 second to run, then the time_now ends up being 12:00:01 (time_now) - 1 second = 12:00:00 instead of 12:00:00 (time_now) - 1 second = 11:59:59.
The croniter is searching for the next run time based on the specified start_at value. So, if the start_at is 12:00 and the scheduled email is supposed to run at 12:00, then croniter won't find anything since 12:00 has already passed.
For example, if the start_at is 12:00:00, it finds the next day:
Whereas if the base start datetime is 11:59:59, it picks up the cron job:
Expected results
Scheduled report gets sent to the provided email - "Scheduling alert" and "Report sent to email" logs are visible.
Actual results
Scheduled report does not get sent to the provided email randomly. There are no error log indicating that there was a failure - "Scheduling alert" and "Report sent to email" messages are not in the logs
Environment
2.0
3.9
v16.17.1
The text was updated successfully, but these errors were encountered: