GH-109369: Exit tier 2 if executor is invalid (GH-111657)

This commit is contained in:
Mark Shannon 2023-11-09 11:19:51 +00:00 committed by GitHub
parent 6046aec377
commit 25c4956488
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 348 additions and 230 deletions

View file

@ -1790,3 +1790,28 @@ class TestOptimizer(MonitoringTestBase, unittest.TestCase):
test_func(1000)
sys.monitoring.set_local_events(TEST_TOOL, code, 0)
self.assertEqual(sys.monitoring.get_local_events(TEST_TOOL, code), 0)
class TestTier2Optimizer(CheckEvents):
def test_monitoring_already_opimized_loop(self):
def test_func(recorder):
set_events = sys.monitoring.set_events
line = E.LINE
i = 0
for i in range(551):
# Turn on events without branching once i reaches 500.
set_events(TEST_TOOL, line * int(i >= 500))
pass
pass
pass
self.assertEqual(sys.monitoring._all_events(), {})
events = []
recorder = LineRecorder(events)
sys.monitoring.register_callback(TEST_TOOL, E.LINE, recorder)
try:
test_func(recorder)
finally:
sys.monitoring.register_callback(TEST_TOOL, E.LINE, None)
sys.monitoring.set_events(TEST_TOOL, 0)
self.assertGreater(len(events), 250)