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

Commit

Permalink
Merge pull request #1731 from matrix-org/markjh/logging-memleak
Browse files Browse the repository at this point in the history
Use the new twisted logging framework.
  • Loading branch information
NegativeMjark authored Dec 30, 2016
2 parents f023be9 + 822cb39 commit 0eac4fa
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions synapse/config/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from ._base import Config
from synapse.util.logcontext import LoggingContextFilter
from twisted.python.log import PythonLoggingObserver
from twisted.logger import globalLogBeginner, STDLibLogObserver
import logging
import logging.config
import yaml
Expand Down Expand Up @@ -180,5 +180,15 @@ def sighup(signum, stack):
with open(log_config, 'r') as f:
logging.config.dictConfig(yaml.load(f))

observer = PythonLoggingObserver()
observer.start()
# It's critical to point twisted's internal logging somewhere, otherwise it
# stacks up and leaks kup to 64K object;
# see: https://twistedmatrix.com/trac/ticket/8164
#
# Routing to the python logging framework could be a performance problem if
# the handlers blocked for a long time 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
#
# However this may not be too much of a problem if we are just writing to a file.
observer = STDLibLogObserver()
globalLogBeginner.beginLoggingTo([observer])

0 comments on commit 0eac4fa

Please sign in to comment.