From 1b9e581bd7a80aa5bb0d64e8385a26171affecc9 Mon Sep 17 00:00:00 2001 From: Vito Sansevero Date: Mon, 26 Oct 2026 06:49:48 -0700 Subject: [PATCH] test(history): give the writer's non-blocking checks a 1 s ceiling (#350) py3.13 on macos-latest failed on PR #351 with writer.close(0) taking 0.186 s against a 0.1 s ceiling while another thread held the commit. The blocked path these checks rule out waits up to 3 s (release.wait(3)), so a 1 s ceiling still tells returning at once from waiting for the release, without failing on a loaded shared runner (TESTING.md, #242). --- tests/test_execution_history_writer.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/tests/test_execution_history_writer.py b/tests/test_execution_history_writer.py index df1c5b2d..ec6327d8 100644 --- a/tests/test_execution_history_writer.py +++ b/tests/test_execution_history_writer.py @@ -24,6 +24,13 @@ from utils.execution_history_events import ( ) from utils.execution_history_writer import HistoryWriter +# These calls must return while another thread holds the writer in a step that +# waits up to 3 s (release.wait(3)). 1 s still tells "returned at once" from +# "waited for the release" without failing on a loaded shared runner (#242: +# generous ceilings, never a short wall clock). A 0.1 s ceiling failed at +# 0.19 s on macOS py3.13 (PR #351). +NON_BLOCKING_CEILING = 1.0 + class ManualClock: def __init__(self): @@ -590,10 +597,10 @@ class HistoryWriterTests(unittest.TestCase): before = time.monotonic() self.assertTrue(writer.status().accepting) self.assertTrue(writer.submit(self.finish_command(start))) - self.assertLess(time.monotonic() - before, 0.1) + self.assertLess(time.monotonic() - before, NON_BLOCKING_CEILING) before = time.monotonic() self.assertFalse(writer.close(0)) - self.assertLess(time.monotonic() - before, 0.1) + self.assertLess(time.monotonic() - before, NON_BLOCKING_CEILING) self.assertGreater(writer.context_budget.charged_bytes, 0) self.assertEqual(writer.status().pending, 1) finally: @@ -663,11 +670,11 @@ class HistoryWriterTests(unittest.TestCase): before = time.monotonic() self.assertFalse(writer.submit(self.start_command())) self.assertIsNone(writer.status().epoch) - self.assertLess(time.monotonic() - before, 0.1) + self.assertLess(time.monotonic() - before, NON_BLOCKING_CEILING) self.assertIsNone(self.db.get_execution_run(self.start_command().run_id)) before = time.monotonic() self.assertFalse(writer.close(0.03)) - self.assertLess(time.monotonic() - before, 0.2) + self.assertLess(time.monotonic() - before, NON_BLOCKING_CEILING) release.set() self.wait_for(lambda: not writer.status().alive) self.assertFalse(writer.status().accepting) @@ -958,7 +965,7 @@ class HistoryWriterTests(unittest.TestCase): self.assertTrue(writer.submit(queued)) before = time.monotonic() self.assertFalse(writer.close(0.03)) - self.assertLess(time.monotonic() - before, 0.2) + self.assertLess(time.monotonic() - before, NON_BLOCKING_CEILING) release.set() self.wait_for(lambda: not writer.status().alive) self.assertIsNone(self.db.get_execution_run(queued.run_id))