mirror of
https://github.com/python/cpython.git
synced 2025-11-11 22:55:08 +00:00
logging: Added threading interlock in basicConfig().
This commit is contained in:
parent
c7937791a1
commit
2314fc729b
1 changed files with 22 additions and 16 deletions
|
|
@ -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):
|
||||||
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.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue