Round up scheduled_at to next minute for Cronicle one-shot timing
If scheduled_at has sub-minute seconds (e.g. retry = now+30s), the Cronicle event would fire at the start of that minute before the message is due and find nothing. Round up so it always fires after the due time. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+5
-1
@@ -1,6 +1,6 @@
|
||||
import logging
|
||||
import os
|
||||
from datetime import datetime, timezone
|
||||
from datetime import datetime, timedelta, timezone
|
||||
|
||||
import httpx
|
||||
|
||||
@@ -70,6 +70,10 @@ def _build_timing(scheduled_at: datetime, recurrence: str) -> dict:
|
||||
- monthly: fires every month on the same day-of-month and hour/minute
|
||||
"""
|
||||
utc = scheduled_at.astimezone(timezone.utc)
|
||||
# Round up to the next minute if there are sub-minute seconds so Cronicle
|
||||
# fires after the message is due, not before.
|
||||
if utc.second or utc.microsecond:
|
||||
utc = (utc + timedelta(minutes=1)).replace(second=0, microsecond=0)
|
||||
h, m = utc.hour, utc.minute
|
||||
|
||||
if recurrence == "daily":
|
||||
|
||||
Reference in New Issue
Block a user