summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_logging.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_logging.py')
-rw-r--r--Lib/test/test_logging.py53
1 files changed, 34 insertions, 19 deletions
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py
index f398720..bf1e234 100644
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -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()
#----------------------------------------------------------------------------