From a6a174d9979b50d4e0accac1aaa77bd172d086a6 Mon Sep 17 00:00:00 2001 From: fjetter Date: Fri, 10 Mar 2023 13:14:49 +0100 Subject: [PATCH] restore test_stack_overflow --- distributed/tests/test_profile.py | 38 ++++++++++++++++++------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/distributed/tests/test_profile.py b/distributed/tests/test_profile.py index adb782d2b4b..5e7feebf2f7 100644 --- a/distributed/tests/test_profile.py +++ b/distributed/tests/test_profile.py @@ -356,19 +356,25 @@ def test_call_stack_f_lineno(f_lasti: int, f_lineno: int) -> None: def test_stack_overflow(): - state = create() - frame = None - - def f(i): - if i == 0: - nonlocal frame - frame = sys._current_frames()[threading.get_ident()] - return - else: - return f(i - 1) - - f(sys.getrecursionlimit() - 200) - process(frame, None, state) - assert state["children"] - assert state["count"] - assert merge(state, state, state) + old = sys.getrecursionlimit() + sys.setrecursionlimit(200) + try: + state = create() + frame = None + + def f(i): + if i == 0: + nonlocal frame + frame = sys._current_frames()[threading.get_ident()] + return + else: + return f(i - 1) + + f(sys.getrecursionlimit() - 200) + process(frame, None, state) + assert state["children"] + assert state["count"] + assert merge(state, state, state) + + finally: + sys.setrecursionlimit(old)