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

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