-
-
Notifications
You must be signed in to change notification settings - Fork 482
Closed
Labels
unconfirmed bugA bug report that needs triagingA bug report that needs triaging
Description
Summary
Task loop decorators allow you to pass in a list of datetime.time
objects for a task to run at specific times of day. However, the bot will error if you attempt to pass in tzinfo
as the lib attempts to compare UTC time to an Offset time.
Reproduction Steps
Create a task using the @tasks.loop
decorator, specifying time=[datetime.time(...)]
using tzinfo
. Finally, attempt to start it.
Minimal Reproducible Code
from discord.ext import tasks
from datetime import time
from zoneinfo import ZoneInfo
@tasks.loop(time=[time(hour=0, minute=0, tzinfo=ZoneInfo('Europe/Berlin'))])
async def task():
print("nice")
task.start()
Expected Results
Task should start successfully and print "nice" every midnight in Europe (UTC+2).
Actual Results
An error is thrown pretty much immediately.
Traceback (most recent call last):
File "/home/container/.local/lib/python3.10/site-packages/discord/ext/tasks/__init__.py", line 165, in _loop
self._prepare_time_index()
File "/home/container/.local/lib/python3.10/site-packages/discord/ext/tasks/__init__.py", line 603, in _prepare_time_index
if time >= time_now:
TypeError: can't compare offset-naive and offset-aware times
Intents
All
System Information
- Python v3.10.2-final
- py-cord v2.0.0-beta
- py-cord pkg_resources: v2.0.0b7
- aiohttp v3.7.3
- system info: Linux 5.13.0-39-generic #\44~20.04.1-Ubuntu SMP Thu Mar 24 16:43:35 UTC 2022
Checklist
- I have searched the open issues for duplicates.
- I have shown the entire traceback, if possible.
- I have removed my token from display, if visible.
Metadata
Metadata
Assignees
Labels
unconfirmed bugA bug report that needs triagingA bug report that needs triaging