Commit 2d2d23f0 authored by Vinay Sajip's avatar Vinay Sajip

Added _handlerList to allow shutdown to flush and close handlers in reverse...

Added _handlerList to allow shutdown to flush and close handlers in reverse order of creation (see SF# 1282539)
parent 51c6f2d4
...@@ -544,6 +544,7 @@ class Filterer: ...@@ -544,6 +544,7 @@ class Filterer:
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
_handlers = {} #repository of handlers (for flushing when shutdown called) _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): class Handler(Filterer):
""" """
...@@ -566,6 +567,7 @@ class Handler(Filterer): ...@@ -566,6 +567,7 @@ class Handler(Filterer):
_acquireLock() _acquireLock()
try: #unlikely to raise an exception, but you never know... try: #unlikely to raise an exception, but you never know...
_handlers[self] = 1 _handlers[self] = 1
_handlerList.insert(0, self)
finally: finally:
_releaseLock() _releaseLock()
self.createLock() self.createLock()
...@@ -668,6 +670,7 @@ class Handler(Filterer): ...@@ -668,6 +670,7 @@ class Handler(Filterer):
_acquireLock() _acquireLock()
try: #unlikely to raise an exception, but you never know... try: #unlikely to raise an exception, but you never know...
del _handlers[self] del _handlers[self]
_handlerList.remove(self)
finally: finally:
_releaseLock() _releaseLock()
...@@ -1307,7 +1310,7 @@ def shutdown(): ...@@ -1307,7 +1310,7 @@ def shutdown():
Should be called at application exit. 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 #errors might occur, for example, if files are locked
#we just ignore them #we just ignore them
try: try:
......
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