Skip to content

Commit

Permalink
Fix to routines time based sleeps.
Browse files Browse the repository at this point in the history
  • Loading branch information
EvieePy committed Aug 19, 2023
1 parent fd4cb9d commit 4b9cc85
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion twitchio/ext/routines/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,9 @@ async def _routine(self, *args, **kwargs) -> None:
if self._remaining_iterations == 0:
self._remaining_iterations = self._iterations

iteration: int = 0
while True:
iteration += 1
start = datetime.datetime.now(datetime.timezone.utc)

try:
Expand All @@ -387,7 +389,7 @@ async def _routine(self, *args, **kwargs) -> None:
break

if self._time:
sleep = compute_timedelta(self._time + datetime.timedelta(days=self._completed_loops))
sleep = compute_timedelta(self._time + datetime.timedelta(days=iteration))
else:
sleep = max((start - datetime.datetime.now(datetime.timezone.utc)).total_seconds() + self._delta, 0)

Expand Down

0 comments on commit 4b9cc85

Please sign in to comment.