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