python-arq / arq

Fast job queuing and RPC in python with asyncio and redis.
https://arq-docs.helpmanual.io/
MIT License
2.14k stars 174 forks source link

worker crashes due to naive and tz aware datetime comparison #483

Closed bitsouls closed 2 hours ago

bitsouls commented 2 hours ago

If there's a task in the scheduler that specifies month(s). It will crash the worker on heartbeat.

This job in the schedule crashes arq running on Python 3.12 and arq 0.26.1 cron(jobs.periodic_google_maps_place_discovery, month={1, 4, 7, 10}, day=15, hour=5, minute=0), # 4 times/year

From a brief inspection, it seems like the error is caused by the month filed handler in arq.cron._get_next_dt while all other field handlers construct a new datetime based on the one that's passed as an argument, that handler returns a new naive datetime object. Which is then returned and gets compared to this_hb_cutoff in the worker that is tz aware.

bitsouls commented 1 hour ago

Library version was outdated and not 0.26.1 as I thought.