|
57 | 57 | from synapse.types import JsonDict
|
58 | 58 | from synapse.util import Clock
|
59 | 59 |
|
60 |
| -from tests.utils import setup_test_homeserver as _sth |
61 | 60 |
|
62 | 61 | logger = logging.getLogger(__name__)
|
63 | 62 |
|
@@ -450,14 +449,11 @@ def _(res):
|
450 | 449 | return d
|
451 | 450 |
|
452 | 451 |
|
453 |
| -def setup_test_homeserver(cleanup_func, *args, **kwargs): |
| 452 | +def make_test_homeserver_synchronous(server: HomeServer) -> None: |
454 | 453 | """
|
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. |
457 | 455 | """
|
458 |
| - server = _sth(cleanup_func, *args, **kwargs) |
459 | 456 |
|
460 |
| - # Make the thread pool synchronous. |
461 | 457 | clock = server.get_clock()
|
462 | 458 |
|
463 | 459 | for database in server.get_datastores().databases:
|
@@ -485,15 +481,14 @@ def runInteraction(interaction, *args, **kwargs):
|
485 | 481 |
|
486 | 482 | pool.runWithConnection = runWithConnection
|
487 | 483 | pool.runInteraction = runInteraction
|
| 484 | + # Replace the thread pool with a threadless 'thread' pool |
488 | 485 | pool.threadpool = ThreadPool(clock._reactor)
|
489 | 486 | pool.running = True
|
490 | 487 |
|
491 | 488 | # We've just changed the Databases to run DB transactions on the same
|
492 | 489 | # thread, so we need to disable the dedicated thread behaviour.
|
493 | 490 | server.get_datastores().main.USE_DEDICATED_DB_THREADS_FOR_EVENT_FETCHING = False
|
494 | 491 |
|
495 |
| - return server |
496 |
| - |
497 | 492 |
|
498 | 493 | def get_clock() -> Tuple[ThreadedMemoryReactorClock, Clock]:
|
499 | 494 | clock = ThreadedMemoryReactorClock()
|
|
0 commit comments