Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
gh-134323: Fix the newthreading.RLock.locked
method#134368
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
ab32409
f303d34
8ae2fc2
9b26b7b
b448d4b
26d4bf4
512ff69
2603d50
a0082a3
9e1bf5f
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -370,6 +370,24 @@ def test_locked(self): | ||
lock.release() | ||
self.assertFalse(lock.locked()) | ||
def test_locked_with_2threads(self): | ||
# see gh-134323: check that a rlock which | ||
# is acquired in a different thread, | ||
# is still locked in the main thread. | ||
result = [] | ||
rlock = self.locktype() | ||
YvesDup marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
self.assertFalse(rlock.locked()) | ||
def acquire(): | ||
result.append(rlock.locked()) | ||
rlock.acquire() | ||
YvesDup marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
result.append(rlock.locked()) | ||
with Bunch(acquire, 1): | ||
pass | ||
self.assertTrue(rlock.locked()) | ||
self.assertFalse(result[0]) | ||
self.assertTrue(result[1]) | ||
def test_release_save_unacquired(self): | ||
# Cannot _release_save an unacquired lock | ||
lock = self.locktype() | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -158,7 +158,7 @@ def __repr__(self): | ||
except KeyError: | ||
pass | ||
return "<%s %s.%s object owner=%r count=%d at %s>" % ( | ||
"locked" if self.locked() else "unlocked", | ||
self.__class__.__module__, | ||
self.__class__.__qualname__, | ||
owner, | ||
@@ -237,7 +237,7 @@ def __exit__(self, t, v, tb): | ||
def locked(self): | ||
"""Return whether this object is locked.""" | ||
return self._block.locked() | ||
YvesDup marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
# Internal methods used by condition variables | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fix the :meth:`threading.RLock.locked` method. |
Uh oh!
There was an error while loading.Please reload this page.