mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-13 18:22:13 -04:00
Allow enabling the asyncio reactor in complement (#14858)
Signed-off-by: Jason Little realtyem@gmail.com
This commit is contained in:
parent
1d3a54aa30
commit
58214dbb9b
6 changed files with 42 additions and 4 deletions
|
@ -110,6 +110,8 @@ def _worker_entrypoint(
|
|||
and then kick off the worker's main() function.
|
||||
"""
|
||||
|
||||
from synapse.util.stringutils import strtobool
|
||||
|
||||
sys.argv = args
|
||||
|
||||
# reset the custom signal handlers that we installed, so that the children start
|
||||
|
@ -117,9 +119,24 @@ def _worker_entrypoint(
|
|||
for sig, handler in _original_signal_handlers.items():
|
||||
signal.signal(sig, handler)
|
||||
|
||||
from twisted.internet.epollreactor import EPollReactor
|
||||
# Install the asyncio reactor if the
|
||||
# SYNAPSE_COMPLEMENT_FORKING_LAUNCHER_ASYNC_IO_REACTOR is set to 1. The
|
||||
# SYNAPSE_ASYNC_IO_REACTOR variable would be used, but then causes
|
||||
# synapse/__init__.py to also try to install an asyncio reactor.
|
||||
if strtobool(
|
||||
os.environ.get("SYNAPSE_COMPLEMENT_FORKING_LAUNCHER_ASYNC_IO_REACTOR", "0")
|
||||
):
|
||||
import asyncio
|
||||
|
||||
from twisted.internet.asyncioreactor import AsyncioSelectorReactor
|
||||
|
||||
reactor = AsyncioSelectorReactor(asyncio.get_event_loop())
|
||||
proxy_reactor._install_real_reactor(reactor)
|
||||
else:
|
||||
from twisted.internet.epollreactor import EPollReactor
|
||||
|
||||
proxy_reactor._install_real_reactor(EPollReactor())
|
||||
|
||||
proxy_reactor._install_real_reactor(EPollReactor())
|
||||
func()
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue