This repository was archived by the owner on Apr 26, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +42
-4
lines changed Expand file tree Collapse file tree 6 files changed +42
-4
lines changed Original file line number Diff line number Diff line change @@ -541,8 +541,11 @@ jobs:
541541
542542 - run : |
543543 set -o pipefail
544- POSTGRES=${{ (matrix.database == 'Postgres') && 1 || '' }} WORKERS=${{ (matrix.arrangement == 'workers') && 1 || '' }} COMPLEMENT_DIR=`pwd`/complement synapse/scripts-dev/complement.sh -json 2>&1 | synapse/.ci/scripts/gotestfmt
544+ COMPLEMENT_DIR=`pwd`/complement synapse/scripts-dev/complement.sh -json 2>&1 | synapse/.ci/scripts/gotestfmt
545545 shell: bash
546+ env:
547+ POSTGRES: ${{ (matrix.database == 'Postgres') && 1 || '' }}
548+ WORKERS: ${{ (matrix.arrangement == 'workers') && 1 || '' }}
546549 name: Run Complement Tests
547550
548551 cargo-test :
Original file line number Diff line number Diff line change 1+ Run the integration test suites with the asyncio reactor enabled in CI.
Original file line number Diff line number Diff line change 66
77echo " Complement Synapse launcher"
88echo " Args: $@ "
9- echo " Env: SYNAPSE_COMPLEMENT_DATABASE=$SYNAPSE_COMPLEMENT_DATABASE SYNAPSE_COMPLEMENT_USE_WORKERS=$SYNAPSE_COMPLEMENT_USE_WORKERS "
9+ echo " Env: SYNAPSE_COMPLEMENT_DATABASE=$SYNAPSE_COMPLEMENT_DATABASE SYNAPSE_COMPLEMENT_USE_WORKERS=$SYNAPSE_COMPLEMENT_USE_WORKERS SYNAPSE_COMPLEMENT_USE_ASYNCIO_REACTOR= $SYNAPSE_COMPLEMENT_USE_ASYNCIO_REACTOR "
1010
1111function log {
1212 d=$( date +" %Y-%m-%d %H:%M:%S,%3N" )
7676fi
7777
7878
79+ if [[ -n " $SYNAPSE_COMPLEMENT_USE_ASYNCIO_REACTOR " ]]; then
80+ if [[ -n " $SYNAPSE_USE_EXPERIMENTAL_FORKING_LAUNCHER " ]]; then
81+ export SYNAPSE_COMPLEMENT_FORKING_LAUNCHER_ASYNC_IO_REACTOR=" 1"
82+ else
83+ export SYNAPSE_ASYNC_IO_REACTOR=" 1"
84+ fi
85+ else
86+ export SYNAPSE_ASYNC_IO_REACTOR=" 0"
87+ fi
88+
89+
7990# Add Complement's appservice registration directory, if there is one
8091# (It can be absent when there are no application services in this test!)
8192if [ -d /complement/appservice ]; then
Original file line number Diff line number Diff line change @@ -332,6 +332,7 @@ The above will run a monolithic (single-process) Synapse with SQLite as the data
332332 [here](https://github.com/matrix-org/synapse/blob/develop/docker/configure_workers_and_start.py#L54).
333333 A safe example would be `WORKER_TYPES="federation_inbound, federation_sender, synchrotron"`.
334334 See the [worker documentation](../workers.md) for additional information on workers.
335+ - Passing `ASYNCIO_REACTOR=1` as an environment variable to use the Twisted asyncio reactor instead of the default one.
335336
336337To increase the log level for the tests, set `SYNAPSE_TEST_LOG_LEVEL`, e.g:
337338```sh
Original file line number Diff line number Diff line change @@ -228,6 +228,11 @@ else
228228 test_tags=" $test_tags ,msc2716"
229229fi
230230
231+ if [[ -n " $ASYNCIO_REACTOR " ]]; then
232+ # Enable the Twisted asyncio reactor
233+ export PASS_SYNAPSE_COMPLEMENT_USE_ASYNCIO_REACTOR=true
234+ fi
235+
231236
232237if [[ -n " $SYNAPSE_TEST_LOG_LEVEL " ]]; then
233238 # Set the log level to what is desired
Original file line number Diff line number Diff line change @@ -110,16 +110,33 @@ def _worker_entrypoint(
110110 and then kick off the worker's main() function.
111111 """
112112
113+ from synapse .util .stringutils import strtobool
114+
113115 sys .argv = args
114116
115117 # reset the custom signal handlers that we installed, so that the children start
116118 # from a clean slate.
117119 for sig , handler in _original_signal_handlers .items ():
118120 signal .signal (sig , handler )
119121
120- from twisted .internet .epollreactor import EPollReactor
122+ # Install the asyncio reactor if the
123+ # SYNAPSE_COMPLEMENT_FORKING_LAUNCHER_ASYNC_IO_REACTOR is set to 1. The
124+ # SYNAPSE_ASYNC_IO_REACTOR variable would be used, but then causes
125+ # synapse/__init__.py to also try to install an asyncio reactor.
126+ if strtobool (
127+ os .environ .get ("SYNAPSE_COMPLEMENT_FORKING_LAUNCHER_ASYNC_IO_REACTOR" , "0" )
128+ ):
129+ import asyncio
130+
131+ from twisted .internet .asyncioreactor import AsyncioSelectorReactor
132+
133+ reactor = AsyncioSelectorReactor (asyncio .get_event_loop ())
134+ proxy_reactor ._install_real_reactor (reactor )
135+ else :
136+ from twisted .internet .epollreactor import EPollReactor
137+
138+ proxy_reactor ._install_real_reactor (EPollReactor ())
121139
122- proxy_reactor ._install_real_reactor (EPollReactor ())
123140 func ()
124141
125142
You can’t perform that action at this time.
0 commit comments