]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-106238: Handle KeyboardInterrupt during logging._acquireLock() (GH-106239)
authorAriel Eizenberg <ariel.eizenberg@gmail.com>
Thu, 6 Jul 2023 07:02:22 +0000 (10:02 +0300)
committerGitHub <noreply@github.com>
Thu, 6 Jul 2023 07:02:22 +0000 (08:02 +0100)
Co-authored-by: Ariel Eizenberg <ariel.eizenberg@pagaya.com>
Lib/logging/__init__.py
Misc/NEWS.d/next/Library/2023-06-29-12-40-52.gh-issue-106238.VulKb9.rst [new file with mode: 0644]

index ba2ed44b095071fd8768963c2bd96c25cdfa860e..fe2039af0334a0f9696e5b42f6e2c2760f46e449 100644 (file)
@@ -238,7 +238,11 @@ def _acquireLock():
     This should be released with _releaseLock().
     """
     if _lock:
-        _lock.acquire()
+        try:
+            _lock.acquire()
+        except BaseException:
+            _lock.release()
+            raise
 
 def _releaseLock():
     """
diff --git a/Misc/NEWS.d/next/Library/2023-06-29-12-40-52.gh-issue-106238.VulKb9.rst b/Misc/NEWS.d/next/Library/2023-06-29-12-40-52.gh-issue-106238.VulKb9.rst
new file mode 100644 (file)
index 0000000..52e7838
--- /dev/null
@@ -0,0 +1 @@
+Fix rare concurrency bug in lock acquisition by the logging package.