[issue26608] RLock undocumented behavior in case of multiple acquire
New submission from Mateusz: The number of acquisitions must be the same as the number of releases or else lock will not be released for other threads leading to deadlock. This is not mentioned in documentation. First acquisition returns boolean and further acquisitions return 1. This is also not mentioned in documentation. ---------- assignee: docs@python components: Documentation, Library (Lib) messages: 262165 nosy: docs@python, smbrd priority: normal severity: normal status: open title: RLock undocumented behavior in case of multiple acquire versions: Python 2.7 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26608> _______________________________________
Josh Rosenberg added the comment: Per the docs ( https://docs.python.org/3/library/threading.html#rlock-objects ): "To unlock the lock, a thread calls its release() method. acquire()/release() call pairs may be nested; only the final release() (the release() of the outermost pair) resets the lock to unlocked and allows another thread blocked in acquire() to proceed." The docs aren't super clear on the return type, but they aren't so overly specified as to make returning either True or 1 incorrect; they use lowercase "true" to describe the return value, which doesn't *have* to mean True, just something that evaluates as truthy. In 3.5 at least, it looks like both initial and subsequent acquires are all returning True, even when called without passing an argument; this actually violates the docs, which claim that not passing an argument means "There is no return value" (possibly only when there is contended acquisition, the wording is odd), when in fact a no-argument call returns True just like explicitly passing blocking as True. ---------- nosy: +josh.r _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26608> _______________________________________
ahxxm added the comment: As seen from commit log, all return type are double back-quoted, this could be a rendering error. I think this commit somehow makes it clear that RLock is a thread-level reentrant lock, some code example of suggested usage might be helpful though. ---------- hgrepos: +348 nosy: +ahxxm _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue26608> _______________________________________
participants (3)
-
ahxxm
-
Josh Rosenberg
-
Mateusz