From 222b5a42e722c1304d13b77cd921405c5fc4dfd5 Mon Sep 17 00:00:00 2001 From: zariiii9003 <52598363+zariiii9003@users.noreply.github.com> Date: Mon, 30 Nov 2026 00:35:39 +0000 Subject: [PATCH] test: time listen_only read separately to fix flake on slow runners --- test/back2back_test.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/test/back2back_test.py b/test/back2back_test.py index be8ae4b08..8567f52ab 100644 --- a/test/back2back_test.py +++ b/test/back2back_test.py @@ -450,26 +450,27 @@ def test_listen_only_while_recv_blocks(self): The wrapped bus class has a listen_only property that records when it is set. Events: - Block in recv() with a timeout of 0.3 s on another thread, then + Block in recv() with a timeout of 1.0 s on another thread, then read listen_only and set it to True. Evaluate: - Reading returns within 0.2 s, while recv() still blocks; setting - reaches the wrapped bus only after 0.25 s, once recv() returned. + Reading takes less than 0.5 s, while recv() still blocks; setting + reaches the wrapped bus only after 0.9 s, once recv() returned. """ set_at = [] listen_only = property(lambda _: False, lambda _, value: set_at.append(time())) receiver = ThreadPool(1) with patch.object(type(self.bus2.__wrapped__), "listen_only", listen_only): start = time() - pending = receiver.apply_async(self.bus2.recv, (0.3,)) + pending = receiver.apply_async(self.bus2.recv, (1.0,)) sleep(0.1) # let the receiver take the receive lock + read_start = time() self.assertIs(self.bus2.listen_only, False) - self.assertLess(time() - start, 0.2) + self.assertLess(time() - read_start, 0.5) self.bus2.listen_only = True self.assertEqual(len(set_at), 1) - self.assertGreaterEqual(set_at[0] - start, 0.25) + self.assertGreaterEqual(set_at[0] - start, 0.9) self.assertIsNone(pending.get()) receiver.close()