0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-06-17 18:18:58 +02:00

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.
This commit is contained in:
Olivier Wilkinson (reivilibre) 2021-12-03 11:35:24 +00:00
parent 5640992d17
commit f7ec6e7d9e

View file

@ -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()