Skip to content

Commit 99b99c2

Browse files
committed
start_background_tasks in tests
1 parent 2f235e3 commit 99b99c2

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tests/server.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,6 +1160,16 @@ def setup_test_homeserver(
11601160
with patch("synapse.storage.database.make_pool", side_effect=make_fake_db_pool):
11611161
hs.setup()
11621162

1163+
# Register background tasks required by this server. This must be done
1164+
# somewhat manually due to the background tasks not being registered
1165+
# unless handlers are instantiated.
1166+
#
1167+
# Since, we don't have to worry about `daemonize` (forking the process) in tests, we
1168+
# can just start the background tasks straight away after `hs.setup`. (compare this
1169+
# with where we call `hs.start_background_tasks()` outside of the test environment).
1170+
if hs.config.worker.run_background_tasks:
1171+
hs.start_background_tasks()
1172+
11631173
# Since we've changed the databases to run DB transactions on the same
11641174
# thread, we need to stop the event fetcher hogging that one thread.
11651175
hs.get_datastores().main.USE_DEDICATED_DB_THREADS_FOR_EVENT_FETCHING = False

0 commit comments

Comments
 (0)