RLock - the reentrant lock implementation in Python

The RLock is the reentrant lock implementation from the Python standard library. When a thread acquires an RLock it becomes the owner of the lock. Only the owning thread must call the release method on the RLock object.

Rlock Updated 23 Aug 2025 1 min read

Overview

  • The RLock implements the re-entrant lock in Python. Using RLock a recursive function can acquire the same lock multiple times. If a thread uses the Lock object to acquire() it more than once in a recursive code this will result in a deadlock.
  • RLock has its acquire() and release() methods. The acquire() can acquire the lock more than once by the owning thread. While using RLock, the owning thread has to release the RLock object the same number of times as the acquire() was called.