Commit d1da5365 authored by Vinay Sajip's avatar Vinay Sajip

logging: Added threading interlock in basicConfig().

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