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