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

Commit 8de5c59

Browse files
committed
Use uvloop as an asyncio reactor event loop
1 parent 5e2cfb6 commit 8de5c59

File tree

3 files changed

+81
-1
lines changed

3 files changed

+81
-1
lines changed

poetry.lock

Lines changed: 71 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ hiredis = { version = "*", optional = true }
207207
Pympler = { version = "*", optional = true }
208208
parameterized = { version = ">=0.7.4", optional = true }
209209
idna = { version = ">=2.5", optional = true }
210+
uvloop = { version = ">=0.17.0", optional = true }
210211

211212
[tool.poetry.extras]
212213
# NB: Packages that should be part of `pip install matrix-synapse[all]` need to be specified
@@ -229,6 +230,7 @@ redis = ["txredisapi", "hiredis"]
229230
# Required to use experimental `caches.track_memory_usage` config option.
230231
cache_memory = ["pympler"]
231232
test = ["parameterized", "idna"]
233+
uvloop = ["uvloop"]
232234

233235
# The duplication here is awful. I hate hate hate hate hate it. However, for now I want
234236
# to ensure you can still `pip install matrix-synapse[all]` like today. Two motivations:
@@ -260,6 +262,8 @@ all = [
260262
"txredisapi", "hiredis",
261263
# cache_memory
262264
"pympler",
265+
# uvloop
266+
"uvloop",
263267
# omitted:
264268
# - test: it's useful to have this separate from dev deps in the olddeps job
265269
# - systemd: this is a system-based requirement

synapse/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@
4444

4545
from twisted.internet import asyncioreactor
4646

47+
if bool(os.environ.get("SYNAPSE_UVLOOP", False)):
48+
import uvloop
49+
50+
uvloop.install()
51+
print("Using uvloop")
52+
4753
asyncioreactor.install(asyncio.get_event_loop())
4854
except ImportError:
4955
pass

0 commit comments

Comments
 (0)