[Python-checkins] python/dist/src/Lib/logging __init__.py, 1.28, 1.29
vsajip@users.sourceforge.net
vsajip at users.sourceforge.net
Thu Sep 8 20:14:19 CEST 2005
Update of /cvsroot/python/python/dist/src/Lib/logging
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30247
Modified Files:
__init__.py
Log Message:
Added _handlerList to allow shutdown to flush and close handlers in reverse order of creation (see SF# 1282539)
Index: __init__.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/logging/__init__.py,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- __init__.py 2 Sep 2005 11:20:33 -0000 1.28
+++ __init__.py 8 Sep 2005 18:14:16 -0000 1.29
@@ -544,6 +544,7 @@
#---------------------------------------------------------------------------
_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 @@
_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 @@
_acquireLock()
try: #unlikely to raise an exception, but you never know...
del _handlers[self]
+ _handlerList.remove(self)
finally:
_releaseLock()
@@ -1307,7 +1310,7 @@
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:
More information about the Python-checkins
mailing list