Skip to content

Commit

Permalink
gh-128167: Document another difference between RLock and Lock
Browse files Browse the repository at this point in the history
RLock is fully released when the acquiring thread returns while Lock remains locked when its acquiring thread returns.
  • Loading branch information
lzlarryli authored Dec 22, 2024
1 parent 8d9f52a commit 9d6fee2
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Doc/library/threading.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down

0 comments on commit 9d6fee2

Please sign in to comment.