Kaydet (Commit) 02dd994a authored tarafından Vinay Sajip's avatar Vinay Sajip

Added exception handling during handler initialization in fileConfig()

üst 1cc37380
...@@ -98,6 +98,7 @@ def fileConfig(fname, defaults=None): ...@@ -98,6 +98,7 @@ def fileConfig(fname, defaults=None):
handlers = {} handlers = {}
fixups = [] #for inter-handler references fixups = [] #for inter-handler references
for hand in hlist: for hand in hlist:
try:
sectname = "handler_%s" % hand sectname = "handler_%s" % hand
klass = cp.get(sectname, "class") klass = cp.get(sectname, "class")
opts = cp.options(sectname) opts = cp.options(sectname)
...@@ -123,6 +124,8 @@ def fileConfig(fname, defaults=None): ...@@ -123,6 +124,8 @@ def fileConfig(fname, defaults=None):
if len(target): #the target handler may not be loaded yet, so keep for later... if len(target): #the target handler may not be loaded yet, so keep for later...
fixups.append((h, target)) fixups.append((h, target))
handlers[hand] = h handlers[hand] = h
except: #if an error occurs when instantiating a handler, too bad
pass #this could happen e.g. because of lack of privileges
#now all handlers are loaded, fixup inter-handler references... #now all handlers are loaded, fixup inter-handler references...
for fixup in fixups: for fixup in fixups:
h = fixup[0] h = fixup[0]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment