Skip to content

Commit aa8411c

Browse files
committed
Reset the actor restart limit in the fixture
Now that actors are stopped properly, we can reestablish the restart limit after it was changed. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent 3fd9489 commit aa8411c

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

tests/conftest.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,10 @@
1212

1313

1414
@pytest.fixture(scope="session", autouse=True)
15-
def disable_actor_auto_restart(): # type: ignore
16-
"""Disable auto-restart of actors while running tests.
17-
18-
At some point we had a version that would set the limit back to the
19-
original value but it doesn't work because some actors will keep running
20-
even after the end of the session and fail after the original value was
21-
reestablished, getting into an infinite loop again.
22-
23-
Note: Test class must derive after unittest.IsolatedAsyncioTestCase.
24-
Otherwise this fixture won't run.
25-
"""
26-
_actor.Actor._restart_limit = 0 # pylint: disable=protected-access
15+
def disable_actor_auto_restart() -> collections.abc.Iterator[None]:
16+
"""Disable auto-restart of actors while running tests."""
17+
# pylint: disable=protected-access
18+
original_limit = _actor.Actor._restart_limit
19+
_actor.Actor._restart_limit = 0
20+
yield
21+
_actor.Actor._restart_limit = original_limit

0 commit comments

Comments
 (0)