Added lock acquisition/release around shared data structure manipulation
This commit is contained in:
parent
bd3490abdb
commit
1eb77a50c8
|
@ -466,9 +466,13 @@ def test4():
|
|||
conf = globals()['config%d' % i]
|
||||
sys.stdout.write('config%d: ' % i)
|
||||
loggerDict = logging.getLogger().manager.loggerDict
|
||||
saved_handlers = logging._handlers.copy()
|
||||
saved_handler_list = logging._handlerList[:]
|
||||
saved_loggers = loggerDict.copy()
|
||||
logging._acquireLock()
|
||||
try:
|
||||
saved_handlers = logging._handlers.copy()
|
||||
saved_handler_list = logging._handlerList[:]
|
||||
saved_loggers = loggerDict.copy()
|
||||
finally:
|
||||
logging._releaseLock()
|
||||
try:
|
||||
fn = tempfile.mktemp(".ini")
|
||||
f = open(fn, "w")
|
||||
|
@ -483,12 +487,16 @@ def test4():
|
|||
message('ok.')
|
||||
os.remove(fn)
|
||||
finally:
|
||||
logging._handlers.clear()
|
||||
logging._handlers.update(saved_handlers)
|
||||
logging._handlerList = saved_handler_list
|
||||
loggerDict = logging.getLogger().manager.loggerDict
|
||||
loggerDict.clear()
|
||||
loggerDict.update(saved_loggers)
|
||||
logging._acquireLock()
|
||||
try:
|
||||
logging._handlers.clear()
|
||||
logging._handlers.update(saved_handlers)
|
||||
logging._handlerList = saved_handler_list
|
||||
loggerDict = logging.getLogger().manager.loggerDict
|
||||
loggerDict.clear()
|
||||
loggerDict.update(saved_loggers)
|
||||
finally:
|
||||
logging._releaseLock()
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Test 5
|
||||
|
@ -527,9 +535,13 @@ class FriendlyFormatter (logging.Formatter):
|
|||
|
||||
def test5():
|
||||
loggerDict = logging.getLogger().manager.loggerDict
|
||||
saved_handlers = logging._handlers.copy()
|
||||
saved_handler_list = logging._handlerList[:]
|
||||
saved_loggers = loggerDict.copy()
|
||||
logging._acquireLock()
|
||||
try:
|
||||
saved_handlers = logging._handlers.copy()
|
||||
saved_handler_list = logging._handlerList[:]
|
||||
saved_loggers = loggerDict.copy()
|
||||
finally:
|
||||
logging._releaseLock()
|
||||
try:
|
||||
fn = tempfile.mktemp(".ini")
|
||||
f = open(fn, "w")
|
||||
|
@ -542,13 +554,16 @@ def test5():
|
|||
logging.exception("just testing")
|
||||
os.remove(fn)
|
||||
finally:
|
||||
logging._handlers.clear()
|
||||
logging._handlers.update(saved_handlers)
|
||||
logging._handlerList = saved_handler_list
|
||||
loggerDict = logging.getLogger().manager.loggerDict
|
||||
loggerDict.clear()
|
||||
loggerDict.update(saved_loggers)
|
||||
|
||||
logging._acquireLock()
|
||||
try:
|
||||
logging._handlers.clear()
|
||||
logging._handlers.update(saved_handlers)
|
||||
logging._handlerList = saved_handler_list
|
||||
loggerDict = logging.getLogger().manager.loggerDict
|
||||
loggerDict.clear()
|
||||
loggerDict.update(saved_loggers)
|
||||
finally:
|
||||
logging._releaseLock()
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue