logging: Added threading interlock in basicConfig().

This commit is contained in:
Vinay Sajip 2010-09-11 09:06:21 +00:00
parent 588bd847fb
commit 1ab32f6ebe

View file

@ -1497,6 +1497,10 @@ def basicConfig(**kwargs):
using sys.stdout or sys.stderr), whereas FileHandler closes its stream
when the handler is closed.
"""
# Add thread safety in case someone mistakenly calls
# basicConfig() from multiple threads
_acquireLock()
try:
if len(root.handlers) == 0:
filename = kwargs.get("filename")
if filename:
@ -1513,6 +1517,8 @@ def basicConfig(**kwargs):
level = kwargs.get("level")
if level is not None:
root.setLevel(level)
finally:
_releaseLock()
#---------------------------------------------------------------------------
# Utility functions at module level.