From cd8bbcd2bb229cdf5c759de8e21f17dcefcc6355 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Fri, 8 Aug 2025 14:05:33 +0000 Subject: [PATCH] tests: don't block forever if a prior unit test raised during setUp --- tests/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/__init__.py b/tests/__init__.py index 51decf3bb..492c295e1 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -55,7 +55,11 @@ class ElectrumTestCase(unittest.IsolatedAsyncioTestCase, Logger): constants.BitcoinMainnet.set_as_network() def setUp(self): - self._test_lock.acquire() + have_lock = self._test_lock.acquire(timeout=0.1) + if not have_lock: + # This can happen when trying to run the tests in parallel, + # or if a prior test raised during `setUp` or `asyncSetUp` and never released the lock. + raise Exception("timed out waiting for test_lock") super().setUp() self.electrum_path = tempfile.mkdtemp(prefix="electrum-unittest-base-") assert util._asyncio_event_loop is None, "global event loop already set?!"