Skip to content

Commit 99b00ef

Browse files
gh-106238: Handle KeyboardInterrupt during logging._acquireLock() (GH-106239)
Co-authored-by: Ariel Eizenberg <[email protected]>
1 parent 38aa89a commit 99b00ef

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

Lib/logging/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,11 @@ def _acquireLock():
238238
This should be released with _releaseLock().
239239
"""
240240
if _lock:
241-
_lock.acquire()
241+
try:
242+
_lock.acquire()
243+
except BaseException:
244+
_lock.release()
245+
raise
242246

243247
def _releaseLock():
244248
"""
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix rare concurrency bug in lock acquisition by the logging package.

0 commit comments

Comments
 (0)