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

Commit dc37b68

Browse files
authored
Parse SYNAPSE_ASYNC_IO_REACTOR env variable & log the reactor on startup (#14092)
1 parent 8faf724 commit dc37b68

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

changelog.d/14092.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Run the integration test suites with the asyncio reactor enabled in CI.

synapse/__init__.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,32 +21,30 @@
2121
import sys
2222

2323
from synapse.util.rust import check_rust_lib_up_to_date
24+
from synapse.util.stringutils import strtobool
2425

2526
# Check that we're not running on an unsupported Python version.
2627
if sys.version_info < (3, 7):
2728
print("Synapse requires Python 3.7 or above.")
2829
sys.exit(1)
2930

3031
# Allow using the asyncio reactor via env var.
31-
if bool(os.environ.get("SYNAPSE_ASYNC_IO_REACTOR", False)):
32-
try:
33-
from incremental import Version
32+
if strtobool(os.environ.get("SYNAPSE_ASYNC_IO_REACTOR", "0")):
33+
from incremental import Version
3434

35-
import twisted
35+
import twisted
3636

37-
# We need a bugfix that is included in Twisted 21.2.0:
38-
# https://twistedmatrix.com/trac/ticket/9787
39-
if twisted.version < Version("Twisted", 21, 2, 0):
40-
print("Using asyncio reactor requires Twisted>=21.2.0")
41-
sys.exit(1)
37+
# We need a bugfix that is included in Twisted 21.2.0:
38+
# https://twistedmatrix.com/trac/ticket/9787
39+
if twisted.version < Version("Twisted", 21, 2, 0):
40+
print("Using asyncio reactor requires Twisted>=21.2.0")
41+
sys.exit(1)
4242

43-
import asyncio
43+
import asyncio
4444

45-
from twisted.internet import asyncioreactor
45+
from twisted.internet import asyncioreactor
4646

47-
asyncioreactor.install(asyncio.get_event_loop())
48-
except ImportError:
49-
pass
47+
asyncioreactor.install(asyncio.get_event_loop())
5048

5149
# Twisted and canonicaljson will fail to import when this file is executed to
5250
# get the __version__ during a fresh install. That's OK and subsequent calls to

synapse/config/logger.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,8 @@ def setup_logging(
326326
logBeginner: The Twisted logBeginner to use.
327327
328328
"""
329+
from twisted.internet import reactor
330+
329331
log_config_path = (
330332
config.worker.worker_log_config
331333
if use_worker_options
@@ -348,3 +350,4 @@ def setup_logging(
348350
)
349351
logging.info("Server hostname: %s", config.server.server_name)
350352
logging.info("Instance name: %s", hs.get_instance_name())
353+
logging.info("Twisted reactor: %s", type(reactor).__name__)

0 commit comments

Comments
 (0)