Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

"AttributeError: 'zoneinfo.ZoneInfo' object has no attribute 'localize'" when using tzlocal 3.x and functions running on cronish intervals / scheduled functions #1504

Closed
kalaspuff opened this issue Aug 17, 2021 · 0 comments · Fixed by #1505
Assignees
Labels
bug Bug reports scheduling Functionality related to scheduling of tasks

Comments

@kalaspuff
Copy link
Owner

A few days tzlocal 3.0 was released. When using that version the following error is produced when starting a service that uses "scheduled" functions:

$ python -m tomodachi.run examples/basic_examples/scheduler_example.py

2021-08-17 13:03:53,786 (services.scheduler_example): Initializing service "example-scheduler-service" [id: eb7ac075-9177-417a-9e82-c933209b89ae]
2021-08-17 13:03:53,796 (services.scheduler_example): Failed to start service
2021-08-17 13:03:53,796 (exception): Uncaught exception: Invalid interval

Traceback (most recent call last):
  File "tomodachi/transport/schedule.py", line 240, in next_call_at
    interval_value, local_tz.localize(datetime.datetime.fromtimestamp(current_time + 1)).astimezone(tz)
AttributeError: 'zoneinfo.ZoneInfo' object has no attribute 'localize'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "tomodachi/container.py", line 178, in run_until_complete
    raise cast(Exception, exception[0])
  File "tomodachi/transport/schedule.py", line 555, in _schedule
    cls.next_call_at(
  File "tomodachi/transport/schedule.py", line 246, in next_call_at
    raise Exception("Invalid interval")
Exception: Invalid interval

2021-08-17 13:03:53,796 (services.scheduler_example): Stopping service "example-scheduler-service" [id: eb7ac075-9177-417a-9e82-c933209b89ae]
2021-08-17 13:03:53,796 (services.scheduler_example): Stopped service "example-scheduler-service" [id: eb7ac075-9177-417a-9e82-c933209b89ae]

Additionally the test tests/test_schedule_service.py::test_schedule_service fails when using tzlocal 3.x.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Bug reports scheduling Functionality related to scheduling of tasks
Projects
None yet
1 participant