sibson / redbeat

RedBeat is a Celery Beat Scheduler that stores the scheduled tasks and runtime metadata in Redis.
Apache License 2.0
891 stars 128 forks source link

Updated to 2.1.1 from 2.0.0 now it fails to run. #251

Open hvdklauw opened 1 year ago

hvdklauw commented 1 year ago

On this line: https://github.com/sibson/redbeat/blame/2012b23f890ad5a25e082b03daf8a4a2a3db6536/redbeat/decoder.py#L84 with AttributeError: 'NoneType' object has no attribute 'total_seconds'

Why would the timezone be set to a number of seconds anyway?

rafaelquintanilha commented 1 year ago

Seeing the same error. For now, pinning the version to 2.0.0.

sibson commented 1 year ago

It looks like the logic was if no known timezone, then encode the timezone as a UTC offset. I'm not sure what the correct equivalent behaviour should be. What are the timezone settings you are using?

hvdklauw commented 1 year ago

According to sentry obj is: datetime.datetime(2023, 6, 20, 14, 23, 1, 599274, tzinfo=<DstTzInfo 'Europe/Amsterdam' CEST+2:00:00 DST>)

hvdklauw commented 1 year ago
import datetime
import pytz

eu_ams = pytz.timezone('Europe/Amsterdam')
obj = eu_ams.localize(datetime.datetime(2023, 6, 20, 14, 23, 1, 599274))

Gives me a datetime object as given there. Now obj.tzinfo.utcoffset expects a datetime as parameter, passing in None there returns None.

The correct way would be:

obj.tzinfo.utcoffset(obj).total_seconds()

which gives 7200.0 as is expected.

But the better way would be to just use the datetime object directly:

obj.utcoffset().total_seconds()
hbradlow commented 12 months ago

We had the same issue and resolved it by pinning to 2.0.0. Is there a solution planned to fix 2.1.1?

hvdklauw commented 5 months ago

So, am I to understand this is fixed in 2.2.0?