diff options
author | Calum Lind <calumlind+deluge@gmail.com> | 2016-10-11 11:26:52 +0100 |
---|---|---|
committer | Calum Lind <calumlind+deluge@gmail.com> | 2016-10-18 18:40:25 +0100 |
commit | 9dd3b1617d44d717fc8d2844d40bd61969c1a157 (patch) | |
tree | ad4d29f211bf4cc5d4642ba50128c48efa6459f3 /deluge/log.py | |
parent | 58835eeb2ea974962527d9848b18c6560b7ff881 (diff) | |
download | deluge-9dd3b1617d44d717fc8d2844d40bd61969c1a157.tar.gz deluge-9dd3b1617d44d717fc8d2844d40bd61969c1a157.tar.bz2 deluge-9dd3b1617d44d717fc8d2844d40bd61969c1a157.zip |
[#2889] Fixes for 'Too many files open' error
* Ensure all file descriptors are closed. Using the with statement ensures
closure.
* The main problem was with thousands of unclosed file desciptors from
tracker_icons mkstemp.
* Use a prefix 'deluge_ticon.' to identify created tracker_icon tmp files.
Diffstat (limited to 'deluge/log.py')
-rw-r--r-- | deluge/log.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/deluge/log.py b/deluge/log.py index 0732f84a0..faf2a011f 100644 --- a/deluge/log.py +++ b/deluge/log.py @@ -203,15 +203,16 @@ def tweak_logging_levels(): log = logging.getLogger(__name__) log.warn("logging.conf found! tweaking logging levels from %s", logging_config_file) - for line in open(logging_config_file, "r").readlines(): - if line.strip().startswith("#"): - continue - name, level = line.strip().split(":") - if level not in levels: - continue - - log.warn("Setting logger \"%s\" to logging level \"%s\"", name, level) - set_logger_level(level, name) + with open(logging_config_file, "r") as _file: + for line in _file: + if line.strip().startswith("#"): + continue + name, level = line.strip().split(":") + if level not in levels: + continue + + log.warn("Setting logger \"%s\" to logging level \"%s\"", name, level) + set_logger_level(level, name) def set_logger_level(level, logger_name=None): |