Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit f7ec6e7

Browse files
committed
Convert one of the setup_test_homeservers 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 parent 5640992 commit f7ec6e7

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

tests/server.py

+3-8
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
from synapse.types import JsonDict
5858
from synapse.util import Clock
5959

60-
from tests.utils import setup_test_homeserver as _sth
6160

6261
logger = logging.getLogger(__name__)
6362

@@ -450,14 +449,11 @@ def _(res):
450449
return d
451450

452451

453-
def setup_test_homeserver(cleanup_func, *args, **kwargs):
452+
def make_test_homeserver_synchronous(server: HomeServer) -> None:
454453
"""
455-
Set up a synchronous test server, driven by the reactor used by
456-
the homeserver.
454+
Make the given test homeserver's database interactions synchronous.
457455
"""
458-
server = _sth(cleanup_func, *args, **kwargs)
459456

460-
# Make the thread pool synchronous.
461457
clock = server.get_clock()
462458

463459
for database in server.get_datastores().databases:
@@ -485,15 +481,14 @@ def runInteraction(interaction, *args, **kwargs):
485481

486482
pool.runWithConnection = runWithConnection
487483
pool.runInteraction = runInteraction
484+
# Replace the thread pool with a threadless 'thread' pool
488485
pool.threadpool = ThreadPool(clock._reactor)
489486
pool.running = True
490487

491488
# We've just changed the Databases to run DB transactions on the same
492489
# thread, so we need to disable the dedicated thread behaviour.
493490
server.get_datastores().main.USE_DEDICATED_DB_THREADS_FOR_EVENT_FETCHING = False
494491

495-
return server
496-
497492

498493
def get_clock() -> Tuple[ThreadedMemoryReactorClock, Clock]:
499494
clock = ThreadedMemoryReactorClock()

0 commit comments

Comments
 (0)