Skip to content

Commit

Permalink
Fix negative expires_ms and avoid worker freezing while using cron (#479
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Matvey-Kuk authored Jan 6, 2025
1 parent 2f752e2 commit 3bacb07
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion arq/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,12 @@ async def run_cron(self, n: datetime, delay: float, num_windows: int = 2) -> Non
job_id = f'{cron_job.name}:{to_unix_ms(cron_job.next_run)}' if cron_job.unique else None
job_futures.add(
self.pool.enqueue_job(
cron_job.name, _job_id=job_id, _queue_name=self.queue_name, _defer_until=cron_job.next_run
cron_job.name,
_job_id=job_id,
_queue_name=self.queue_name,
_defer_until=(
cron_job.next_run if cron_job.next_run > datetime.now(tz=self.timezone) else None
),
)
)
cron_job.calculate_next(cron_job.next_run)
Expand Down

0 comments on commit 3bacb07

Please sign in to comment.