| 1 |
From: Colin Watson <[email protected]> |
| 2 |
Date: Mon, 28 Apr 2025 01:41:13 +0100 |
| 3 |
Subject: Close and join thread pools between tests |
| 4 |
|
| 5 |
https://bugs.debian.org/1103066 reported test failures on Debian's i386 |
| 6 |
architecture. After some digging I found that tests were hitting |
| 7 |
`ENOMEM` depending on which other tests had been run previously, |
| 8 |
suggesting test isolation problems; i386 has a more limited address |
| 9 |
space than most other architectures so is more likely to run into this |
| 10 |
sort of thing. Forcing thread pools to be shut down between tests seems |
| 11 |
to avoid this problem. |
| 12 |
|
| 13 |
Forwarded: https://github.com/errbotio/errbot/pull/1724 |
| 14 |
Bug-Debian: https://bugs.debian.org/1103066 |
| 15 |
Last-Update: 2025-04-28 |
| 16 |
--- |
| 17 |
errbot/backends/test.py | 4 ++++ |
| 18 |
tests/base_backend_test.py | 10 ++++++++-- |
| 19 |
2 files changed, 12 insertions(+), 2 deletions(-) |
| 20 |
|
| 21 |
diff --git a/errbot/backends/test.py b/errbot/backends/test.py |
| 22 |
index ed1f57c..8969620 100644 |
| 23 |
--- a/errbot/backends/test.py |
| 24 |
+++ b/errbot/backends/test.py |
| 25 |
@@ -521,6 +521,10 @@ class TestBot: |
| 26 |
log.info("Main bot thread quits") |
| 27 |
self.bot.zap_queues() |
| 28 |
self.bot.reset_rooms() |
| 29 |
+ self.bot.thread_pool.close() |
| 30 |
+ self.bot.thread_pool.join() |
| 31 |
+ self.bot.flow_executor._pool.close() |
| 32 |
+ self.bot.flow_executor._pool.join() |
| 33 |
self.bot_thread = None |
| 34 |
|
| 35 |
def pop_message(self, timeout: int = 5, block: bool = True): |
| 36 |
diff --git a/tests/base_backend_test.py b/tests/base_backend_test.py |
| 37 |
index 5406356..91c526c 100644 |
| 38 |
--- a/tests/base_backend_test.py |
| 39 |
+++ b/tests/base_backend_test.py |
| 40 |
@@ -257,8 +257,14 @@ class DummyBackend(ErrBot): |
| 41 |
|
| 42 |
|
| 43 |
@pytest.fixture |
| 44 |
-def dummy_backend(): |
| 45 |
- return DummyBackend() |
| 46 |
+def dummy_backend(request): |
| 47 |
+ def on_finish(): |
| 48 |
+ backend.flow_executor._pool.close() |
| 49 |
+ backend.flow_executor._pool.join() |
| 50 |
+ |
| 51 |
+ backend = DummyBackend() |
| 52 |
+ request.addfinalizer(on_finish) |
| 53 |
+ return backend |
| 54 |
|
| 55 |
|
| 56 |
def test_buildreply(dummy_backend): |