From: Colin Watson Date: Mon, 28 Apr 2025 01:41:13 +0100 Subject: Close and join thread pools between tests https://bugs.debian.org/1103066 reported test failures on Debian's i386 architecture. After some digging I found that tests were hitting `ENOMEM` depending on which other tests had been run previously, suggesting test isolation problems; i386 has a more limited address space than most other architectures so is more likely to run into this sort of thing. Forcing thread pools to be shut down between tests seems to avoid this problem. Forwarded: https://github.com/errbotio/errbot/pull/1724 Bug-Debian: https://bugs.debian.org/1103066 Last-Update: 2025-04-28 --- errbot/backends/test.py | 4 ++++ tests/base_backend_test.py | 10 ++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/errbot/backends/test.py b/errbot/backends/test.py index ed1f57c..8969620 100644 --- a/errbot/backends/test.py +++ b/errbot/backends/test.py @@ -521,6 +521,10 @@ class TestBot: log.info("Main bot thread quits") self.bot.zap_queues() self.bot.reset_rooms() + self.bot.thread_pool.close() + self.bot.thread_pool.join() + self.bot.flow_executor._pool.close() + self.bot.flow_executor._pool.join() self.bot_thread = None def pop_message(self, timeout: int = 5, block: bool = True): diff --git a/tests/base_backend_test.py b/tests/base_backend_test.py index 5406356..91c526c 100644 --- a/tests/base_backend_test.py +++ b/tests/base_backend_test.py @@ -257,8 +257,14 @@ class DummyBackend(ErrBot): @pytest.fixture -def dummy_backend(): - return DummyBackend() +def dummy_backend(request): + def on_finish(): + backend.flow_executor._pool.close() + backend.flow_executor._pool.join() + + backend = DummyBackend() + request.addfinalizer(on_finish) + return backend def test_buildreply(dummy_backend):