Skip to content

Commit 3bacb07

Browse files
authored
Fix negative expires_ms and avoid worker freezing while using cron (python-arq#479)
1 parent 2f752e2 commit 3bacb07

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

arq/worker.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,12 @@ async def run_cron(self, n: datetime, delay: float, num_windows: int = 2) -> Non
753753
job_id = f'{cron_job.name}:{to_unix_ms(cron_job.next_run)}' if cron_job.unique else None
754754
job_futures.add(
755755
self.pool.enqueue_job(
756-
cron_job.name, _job_id=job_id, _queue_name=self.queue_name, _defer_until=cron_job.next_run
756+
cron_job.name,
757+
_job_id=job_id,
758+
_queue_name=self.queue_name,
759+
_defer_until=(
760+
cron_job.next_run if cron_job.next_run > datetime.now(tz=self.timezone) else None
761+
),
757762
)
758763
)
759764
cron_job.calculate_next(cron_job.next_run)

0 commit comments

Comments
 (0)