Skip to content

Commit ea7c2a2

Browse files
authored
fix first iteration current loop not working
Signed-off-by: Lumouille <[email protected]>
1 parent 51cb3b9 commit ea7c2a2

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

discord/ext/tasks/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
FT = TypeVar("FT", bound=_func)
4949
ET = TypeVar("ET", bound=Callable[[Any, BaseException], Awaitable[Any]])
5050
_current_loop_ctx: contextvars.ContextVar[int] = contextvars.ContextVar(
51-
"_current_loop_ctx", default=0
51+
"_current_loop_ctx", default=None
5252
)
5353

5454

@@ -310,7 +310,11 @@ def time(self) -> list[datetime.time] | None:
310310
@property
311311
def current_loop(self) -> int:
312312
"""The current iteration of the loop."""
313-
return _current_loop_ctx.get() or self._current_loop
313+
return (
314+
_current_loop_ctx.get()
315+
if _current_loop_ctx.get() is not None
316+
else self._current_loop
317+
)
314318

315319
@property
316320
def next_iteration(self) -> datetime.datetime | None:

0 commit comments

Comments
 (0)