Skip to content

Commit ff02ae1

Browse files
committed
Fix routine entering recursive loop with .restart
1 parent 1556f41 commit ff02ae1

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

twitchio/ext/routines/__init__.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,6 @@ async def _call_error(self, error: Exception) -> None:
181181
await self._on_error(error)
182182

183183
async def _routine_loop(self, *args: Any, **kwargs: Any) -> None:
184-
self._args = args
185-
self._kwargs = kwargs
186-
187184
backoff: Backoff = Backoff(base=3, maximum_time=10, maximum_tries=5)
188185

189186
if self._should_stop:
@@ -266,6 +263,22 @@ async def _routine_loop(self, *args: Any, **kwargs: Any) -> None:
266263

267264
self.cancel()
268265

266+
@property
267+
def args(self) -> tuple[Any, ...]:
268+
"""|prop|
269+
270+
Property returning any positional arguments passed to the routine via :meth:`.start`.
271+
"""
272+
return self._args
273+
274+
@property
275+
def kwargs(self) -> Any:
276+
"""|prop|
277+
278+
Property returning any keyword arguments passed to the routine via :meth:`.start`.
279+
"""
280+
return self._kwargs
281+
269282
def start(self, *args: Any, **kwargs: Any) -> asyncio.Task[None]:
270283
r"""Method to start the :class:`~Routine` in the background.
271284
@@ -288,6 +301,9 @@ def start(self, *args: Any, **kwargs: Any) -> asyncio.Task[None]:
288301
if self._task and not self._task.done() and not self._restarting:
289302
raise RuntimeError(f"Routine {self!r} is currently running and has not completed.")
290303

304+
self._args = args
305+
self._kwargs = kwargs
306+
291307
if self._injected:
292308
args = (self._injected, *args)
293309

0 commit comments

Comments
 (0)