summaryrefslogtreecommitdiffstats
path: root/deluge/log.py
diff options
context:
space:
mode:
authorCalum Lind <calumlind+deluge@gmail.com>2016-10-11 11:26:52 +0100
committerCalum Lind <calumlind+deluge@gmail.com>2016-10-18 18:40:25 +0100
commit9dd3b1617d44d717fc8d2844d40bd61969c1a157 (patch)
treead4d29f211bf4cc5d4642ba50128c48efa6459f3 /deluge/log.py
parent58835eeb2ea974962527d9848b18c6560b7ff881 (diff)
downloaddeluge-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.py19
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):