summary refs log tree commit diff
path: root/synapse/app/homeserver.py
diff options
context:
space:
mode:
authorMatthew Hodgson <matthew@matrix.org>2016-12-30 01:05:26 +0000
committerMatthew Hodgson <matthew@matrix.org>2016-12-30 01:05:26 +0000
commit68f5cadcba27bbf75ff7d0f9abcb9e78ddb559c4 (patch)
tree1b44c3879b0e0b9900f24d17564d2b42e6526fd4 /synapse/app/homeserver.py
parentBump changelog and version (diff)
downloadsynapse-68f5cadcba27bbf75ff7d0f9abcb9e78ddb559c4.tar.xz
avoid leaking twisted log events by routing them to python's logging instead github/matthew/logging-memleak matthew/logging-memleak
Diffstat (limited to '')
-rwxr-xr-xsynapse/app/homeserver.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/synapse/app/homeserver.py b/synapse/app/homeserver.py
index 54f35900f8..26425f21c4 100755
--- a/synapse/app/homeserver.py
+++ b/synapse/app/homeserver.py
@@ -38,6 +38,8 @@ from twisted.application import service
 from twisted.web.resource import Resource, EncodingResourceWrapper
 from twisted.web.static import File
 from twisted.web.server import GzipEncoderFactory
+from twisted.logger import globalLogBeginner, STDLibLogObserver
+
 from synapse.http.server import RootRedirect
 from synapse.rest.media.v0.content_repository import ContentRepoResource
 from synapse.rest.media.v1.media_repository import MediaRepositoryResource
@@ -474,6 +476,16 @@ def run(hs):
 
 
 def main():
+
+    # it's critical to point twisted's internal logging somewhere, otherwise it
+    # stacks up and leaks; see: https://twistedmatrix.com/trac/ticket/8164
+    #
+    # XXX: however, routing it to python.logging is apparently a perf problem
+    # as python.logging is a blocking API - see
+    # https://twistedmatrix.com/documents/current/core/howto/logger.html
+    # filed as https://github.com/matrix-org/synapse/issues/1727
+    globalLogBeginner.beginLoggingTo([STDLibLogObserver()])
+
     with LoggingContext("main"):
         # check base requirements
         check_requirements()