8000 gh-87135: threading.Lock: Raise rather than hang on Python finalization by encukou · Pull Request #135991 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-87135: threading.Lock: Raise rather than hang on Python finalization #135991

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 1, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Test locking RLock recursively
  • Loading branch information
encukou committed Jun 27, 2025
commit 59d07fa0688d51a7c6c7b0e1d30815126f5f617e
4 changes: 4 additions & 0 deletions Lib/test/test_threading.py
Original file line number Diff line number Diff line change
Expand Up @@ -1261,6 +1261,8 @@ def test_acquire_daemon_thread_lock_in_finalization(self, lock_class_name):

lock = threading.{lock_class_name}()
def loop():
if {lock_class_name!r} == 'RLock':
lock.acquire()
with lock:
thread_started_event.set()
while True:
Expand All @@ -1281,6 +1283,8 @@ def __del__(self):

# We *can* acquire an unlocked lock
uncontested_lock.acquire()
if {lock_class_name!r} == 'RLock':
uncontested_lock.acquire()

# Acquiring a locked one fails
try:
Expand Down
Loading
0