Blame SOURCES/00362-threading-enumerate-rlock.patch

d7a225
bpo-44422: Fix threading.enumerate() reentrant call (GH-26727)
d7a225
d7a225
The threading.enumerate() function now uses a reentrant lock to
d7a225
prevent a hang on reentrant call.
d7a225
d7a225
https://github.com/python/cpython/commit/243fd01047ddce1a7eb0f99a49732d123e942c63
d7a225
d7a225
Resolves: rhbz#1959459
d7a225
d7a225
diff --git a/Lib/threading.py b/Lib/threading.py
d7a225
index 0ab1e46..7ab9ad8 100644
d7a225
--- a/Lib/threading.py
d7a225
+++ b/Lib/threading.py
d7a225
@@ -727,8 +727,11 @@ _counter() # Consume 0 so first non-main thread has id 1.
d7a225
 def _newname(template="Thread-%d"):
d7a225
     return template % _counter()
d7a225
 
d7a225
-# Active thread administration
d7a225
-_active_limbo_lock = _allocate_lock()
d7a225
+# Active thread administration.
d7a225
+#
d7a225
+# bpo-44422: Use a reentrant lock to allow reentrant calls to functions like
d7a225
+# threading.enumerate().
d7a225
+_active_limbo_lock = RLock()
d7a225
 _active = {}    # maps thread id to Thread object
d7a225
 _limbo = {}
d7a225
 _dangling = WeakSet()
d7a225
@@ -1325,7 +1328,7 @@ def _after_fork():
d7a225
     # Reset _active_limbo_lock, in case we forked while the lock was held
d7a225
     # by another (non-forked) thread.  http://bugs.python.org/issue874900
d7a225
     global _active_limbo_lock, _main_thread
d7a225
-    _active_limbo_lock = _allocate_lock()
d7a225
+    _active_limbo_lock = RLock()
d7a225
 
d7a225
     # fork() only copied the current thread; clear references to others.
d7a225
     new_active = {}