mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
logging: Added threading interlock in basicConfig().
This commit is contained in:
parent
588bd847fb
commit
1ab32f6ebe
1 changed files with 22 additions and 16 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue