From 9d6fee24384c57c05b9aebf01379339ba152574f Mon Sep 17 00:00:00 2001 From: Lizao Li Date: Sat, 21 Dec 2024 23:22:08 -0800 Subject: [PATCH] gh-128167: Document another difference between RLock and Lock RLock is fully released when the acquiring thread returns while Lock remains locked when its acquiring thread returns. --- Doc/library/threading.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Doc/library/threading.rst b/Doc/library/threading.rst index f183f3f535c4cb..5cd2f6991edb1b 100644 --- a/Doc/library/threading.rst +++ b/Doc/library/threading.rst @@ -613,6 +613,13 @@ and "recursion level" in addition to the locked/unlocked state used by primitive locks. In the locked state, some thread owns the lock; in the unlocked state, no thread owns it. +.. note:: + + Reentrant locks are "owned" by the acquiring thread only throughout the + thread's life cycle. In particular, an RLock is silently and fully released + when the acquiring thread returns. This is different from Lock, which remains + locked after its acquiring thread returns. + Threads call a lock's :meth:`~RLock.acquire` method to lock it, and its :meth:`~Lock.release` method to unlock it.