summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2005-09-08 18:14:16 (GMT)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2005-09-08 18:14:16 (GMT)
commit0ee9ba258ec8fd3c600d6ffa28091f2c6fa8d40c (patch)
tree73c539d3d52d23760d510ee478506a9c960d5ace
parente029da0aca41d7ee7f225eb0beedb8acdb0fef75 (diff)
downloadcpython-0ee9ba258ec8fd3c600d6ffa28091f2c6fa8d40c.zip
cpython-0ee9ba258ec8fd3c600d6ffa28091f2c6fa8d40c.tar.gz
cpython-0ee9ba258ec8fd3c600d6ffa28091f2c6fa8d40c.tar.bz2
Added _handlerList to allow shutdown to flush and close handlers in reverse order of creation (see SF# 1282539)
-rw-r--r--Lib/logging/__init__.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py
index 642b4ec..cee5fa2 100644
--- a/Lib/logging/__init__.py
+++ b/Lib/logging/__init__.py
@@ -544,6 +544,7 @@ class Filterer:
#---------------------------------------------------------------------------
_handlers = {} #repository of handlers (for flushing when shutdown called)
+_handlerList = [] # added to allow handlers to be removed in reverse of order initialized
class Handler(Filterer):
"""
@@ -566,6 +567,7 @@ class Handler(Filterer):
_acquireLock()
try: #unlikely to raise an exception, but you never know...
_handlers[self] = 1
+ _handlerList.insert(0, self)
finally:
_releaseLock()
self.createLock()
@@ -668,6 +670,7 @@ class Handler(Filterer):
_acquireLock()
try: #unlikely to raise an exception, but you never know...
del _handlers[self]
+ _handlerList.remove(self)
finally:
_releaseLock()
@@ -1307,7 +1310,7 @@ def shutdown():
Should be called at application exit.
"""
- for h in _handlers.keys():
+ for h in _handlerList[:]: # was _handlers.keys():
#errors might occur, for example, if files are locked
#we just ignore them
try: