Convert one of the `setup_test_homeserver`s to `make_test_homeserver_synchronous`
and pass in the homeserver rather than calling a same-named function to ask for one.
Later commits will jiggle things around to make this sensible.
1 files changed, 3 insertions, 8 deletions
diff --git a/tests/server.py b/tests/server.py
index 40cf5b12c3..41eb3995bd 100644
--- a/tests/server.py
+++ b/tests/server.py
@@ -57,7 +57,6 @@ from synapse.http.site import SynapseRequest
from synapse.types import JsonDict
from synapse.util import Clock
-from tests.utils import setup_test_homeserver as _sth
logger = logging.getLogger(__name__)
@@ -450,14 +449,11 @@ class ThreadPool:
return d
-def setup_test_homeserver(cleanup_func, *args, **kwargs):
+def make_test_homeserver_synchronous(server: HomeServer) -> None:
"""
- Set up a synchronous test server, driven by the reactor used by
- the homeserver.
+ Make the given test homeserver's database interactions synchronous.
"""
- server = _sth(cleanup_func, *args, **kwargs)
- # Make the thread pool synchronous.
clock = server.get_clock()
for database in server.get_datastores().databases:
@@ -485,6 +481,7 @@ def setup_test_homeserver(cleanup_func, *args, **kwargs):
pool.runWithConnection = runWithConnection
pool.runInteraction = runInteraction
+ # Replace the thread pool with a threadless 'thread' pool
pool.threadpool = ThreadPool(clock._reactor)
pool.running = True
@@ -492,8 +489,6 @@ def setup_test_homeserver(cleanup_func, *args, **kwargs):
# thread, so we need to disable the dedicated thread behaviour.
server.get_datastores().main.USE_DEDICATED_DB_THREADS_FOR_EVENT_FETCHING = False
- return server
-
def get_clock() -> Tuple[ThreadedMemoryReactorClock, Clock]:
clock = ThreadedMemoryReactorClock()
|