Comparisons using just the time object without an attached date
are pretty buggy and incomplete -- comparisons only make sense when
given a particular instant of time.
Ref: #7676
This changeset allows app commands defined inside Cog to work as
expected. Likewise, by deriving app_commands.Group and Cog you can
make the cog function as a top level command on Discord.
Relative time intervals can be thought of as:
for _ in range(count):
await body()
await asyncio.sleep(interval)
While explicit time intervals should be thought of as:
times = [1pm, 2pm, 3pm, 12am]
current = 0
for _ in range(count):
time = times.wrapping_index(current) # magic to wrap around
await utils.sleep_until(time)
await body()
current += 1
In a scenario with `tasks.loop(seconds=5)`:
The task takes 30 seconds to run on the first two iterations, and then
is nearly instant for iterations afterward. The behavior should be
that the task runs at:
t = 0 (on time)
t = 30 (late, should've been at t = 5)
t = 60 (late, should've been at t = 10)
t = 60 (late, should've been at t = 15)
t = 60 (late, should've been at t = 20)
t = 60 (late, should've been at t = 25)
... 6 more iterations
t = 60 (on time)
t = 65 (on time)
In a scenario with a loop with explicit times set at UTC 1pm, 2pm,
3pm, 4pm, and 5pm:
- The task takes 6 hour to run on the first iteration, and then is
nearly instant for iterations afterward. Assuming the task is started
at noon, the behavior should be that the task runs at `t = 0` and
then at `t = 3600` 4 times ("catching up" on the missed iterations
at 2pm, 3pm, 4pm, and 5pm).
- The task takes 30 days to run on the first iteration, and then is
nearly instant for iterations afterward. Assuming the task is started
at noon, the behavior should be that the task runs at `t = 0` and
then at `t = 43200` 149 times ("catching up" on the missed
iterations for the past month).
This behavior should be documented in the ext.tasks docs
Segments where readability was hampered were fixed by appropriate
format skipping directives. New code should hopefully be black
compatible. The moment they remove the -S option is probably the moment
I stop using black though.