summaryrefslogtreecommitdiff
path: root/Lib/threading.py
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2014-05-25 18:22:35 -0700
committerRaymond Hettinger <python@rcn.com>2014-05-25 18:22:35 -0700
commit62f4dad81607d8d0a70223ef3feacdfd3aa5e898 (patch)
tree5e4c3b7ccb6ab56240b77da3946c4e0a301c72f3 /Lib/threading.py
parentfa4ed0c145f2e17ccd59c2180cbf7be07c8c872d (diff)
downloadcpython-git-62f4dad81607d8d0a70223ef3feacdfd3aa5e898.tar.gz
Issue 21137: Better repr for threading.Lock()
Diffstat (limited to 'Lib/threading.py')
-rw-r--r--Lib/threading.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/Lib/threading.py b/Lib/threading.py
index 34070830e7..c7c4478178 100644
--- a/Lib/threading.py
+++ b/Lib/threading.py
@@ -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.