Skip to content

Commit fdd18a9

Browse files
Add try/finally to decorated context managers yield statement (#757)
And also log any unhandled caught exception. Closes #721.
2 parents 5e21938 + 8685e9e commit fdd18a9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

tests/conftest.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,11 @@ def actor_restart_limit(limit: int) -> Iterator[None]:
3636
f"<actor_restart_limit> Changing the restart limit from {original_limit} to {limit}"
3737
)
3838
_actor.Actor._restart_limit = limit
39-
yield
40-
print(f"<actor_restart_limit> Resetting restart limit to {original_limit}")
41-
_actor.Actor._restart_limit = original_limit
39+
try:
40+
yield
41+
finally:
42+
print(f"<actor_restart_limit> Resetting restart limit to {original_limit}")
43+
_actor.Actor._restart_limit = original_limit
4244

4345

4446
@pytest.fixture(scope="session", autouse=True)

0 commit comments

Comments
 (0)