Skip to content

Commit 2fc84dd

Browse files
gh-160676: Fix tier-2 monitoring regression test
1 parent 0ba9059 commit 2fc84dd

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

‎Lib/test/test_monitoring.py‎

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2684,12 +2684,23 @@ def test_raise_callback_stop_iteration_in_for_tier2(self):
26842684
threshold = _testinternalcapi.SPECIALIZATION_THRESHOLD
26852685
callback_executor = None
26862686

2687+
class Iterator:
2688+
def __init__(self):
2689+
self.count = 0
2690+
2691+
def __iter__(self):
2692+
return self
2693+
2694+
def __next__(self):
2695+
if self.count < threshold:
2696+
self.count += 1
2697+
return self.count
2698+
sys.monitoring.set_events(TEST_TOOL, E.RAISE)
2699+
raise StopIteration
2700+
26872701
def run():
2688-
for i in range(threshold + 1):
2689-
sys.monitoring.set_events(
2690-
TEST_TOOL,
2691-
E.RAISE if i == threshold else 0,
2692-
)
2702+
for _ in Iterator():
2703+
pass
26932704

26942705
def on_raise(code, offset, exc):
26952706
nonlocal callback_executor

0 commit comments

Comments
 (0)