From c9b61fc2a3d612485a60e5aa4e9c1d13fe1719ce Mon Sep 17 00:00:00 2001 From: Andrew Morgan <1342360+anoadragon453@users.noreply.github.com> Date: Tue, 29 Sep 2026 17:25:32 +0100 Subject: [PATCH] Stop real threadpool for test DB pool before replacing it with threadless test implementation (#20272) --- changelog.d/20272.bugfix | 1 + tests/server.py | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 changelog.d/20272.bugfix diff --git a/changelog.d/20272.bugfix b/changelog.d/20272.bugfix new file mode 100644 index 0000000000..6b545eefcc --- /dev/null +++ b/changelog.d/20272.bugfix @@ -0,0 +1 @@ +Prevent `trial` tests from hanging when running with Twisted 26.4.0 against Postgres. \ No newline at end of file diff --git a/tests/server.py b/tests/server.py index 71f9da9c4c..3d44e11715 100644 --- a/tests/server.py +++ b/tests/server.py @@ -889,9 +889,15 @@ def make_fake_db_pool( pool.runWithConnection = runWithConnection # type: ignore[method-assign] pool.runInteraction = runInteraction # type: ignore[assignment] - # Replace the thread pool with a threadless 'thread' pool + + # First, stop the original thread pool. + pool.threadpool.stop() + # Then, replace it with a threadless 'thread' pool pool.threadpool = ThreadPool(reactor) + + # Start it up. pool.running = True + return pool