bpo-39198: Ensure logging global lock is released on exception in isEnabledFor (GH-17689)
This commit is contained in:
parent
5b23f7618d
commit
950c6795aa
|
@ -1687,12 +1687,15 @@ class Logger(Filterer):
|
|||
return self._cache[level]
|
||||
except KeyError:
|
||||
_acquireLock()
|
||||
if self.manager.disable >= level:
|
||||
is_enabled = self._cache[level] = False
|
||||
else:
|
||||
is_enabled = self._cache[level] = level >= self.getEffectiveLevel()
|
||||
_releaseLock()
|
||||
|
||||
try:
|
||||
if self.manager.disable >= level:
|
||||
is_enabled = self._cache[level] = False
|
||||
else:
|
||||
is_enabled = self._cache[level] = (
|
||||
level >= self.getEffectiveLevel()
|
||||
)
|
||||
finally:
|
||||
_releaseLock()
|
||||
return is_enabled
|
||||
|
||||
def getChild(self, suffix):
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
If an exception were to be thrown in `Logger.isEnabledFor` (say, by asyncio timeouts or stopit) , the `logging` global lock may not be released appropriately, resulting in deadlock. This change wraps that block of code with `try...finally` to ensure the lock is released.
|
Loading…
Reference in New Issue