mirror of
https://github.com/python/cpython.git
synced 2025-08-22 17:55:18 +00:00
Issue 21137: Better repr for threading.Lock()
This commit is contained in:
parent
fa4ed0c145
commit
62f4dad816
6 changed files with 41 additions and 6 deletions
|
@ -106,8 +106,14 @@ class _RLock:
|
|||
owner = _active[owner].name
|
||||
except KeyError:
|
||||
pass
|
||||
return "<%s owner=%r count=%d>" % (
|
||||
self.__class__.__name__, owner, self._count)
|
||||
return "<%s %s.%s object owner=%r count=%d at %s>" % (
|
||||
"locked" if self._block.locked() else "unlocked",
|
||||
self.__class__.__module__,
|
||||
self.__class__.__qualname__,
|
||||
owner,
|
||||
self._count,
|
||||
hex(id(self))
|
||||
)
|
||||
|
||||
def acquire(self, blocking=True, timeout=-1):
|
||||
"""Acquire a lock, blocking or non-blocking.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue