Skip to content

Commit 6d67fb4

Browse files
Rename n_restarts to n_errors in actor run method
Because this nane is more descriptive.
1 parent 304035c commit 6d67fb4

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/frequenz/sdk/actor/_actor.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ async def _run_loop(self) -> None:
8383
BaseException: If the actor's `_run()` method raises any base exception.
8484
"""
8585
_logger.info("Actor %s: Started.", self)
86-
n_restarts = 0
86+
n_errors = 0
8787
should_delay = False
8888
while True:
8989
try:
@@ -102,10 +102,12 @@ async def _run_loop(self) -> None:
102102
should_delay = True
103103
_logger.exception("Actor %s: Raised an unhandled exception.", self)
104104
limit_str = "∞" if self._restart_limit is None else self._restart_limit
105-
limit_str = f"({n_restarts}/{limit_str})"
106-
if self._restart_limit is None or n_restarts < self._restart_limit:
107-
n_restarts += 1
108-
_logger.info("Actor %s: Restarting %s...", self, limit_str)
105+
limit_str = f"({n_errors}/{limit_str})"
106+
if self._restart_limit is None or n_errors < self._restart_limit:
107+
n_errors += 1
108+
_logger.info(
109+
"Actor %s: Restarting, error count %s...", self, limit_str
110+
)
109111
continue
110112
_logger.info(
111113
"Actor %s: Maximum restarts attempted %s, bailing out...",

tests/actor/test_actor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ async def test_restart_on_unhandled_exception(
246246
),
247247
(
248248
*ACTOR_INFO,
249-
f"Actor RaiseExceptionActor[test]: Restarting ({i}/{restart_limit})...",
249+
f"Actor RaiseExceptionActor[test]: Restarting, error count ({i}/{restart_limit})...",
250250
),
251251
(
252252
*ACTOR_INFO,

0 commit comments

Comments
 (0)