[vdsm] [PATCH] Monkeypatch python's thread.allocate_lock

Yaniv Bronhaim ybronhei at redhat.com
Thu Feb 27 13:59:27 UTC 2014


In python's thread package implementation thread.allocate_lock is being used
in each creation of new thread (python.__bootstrap_inner).
Vdsm faced few scenarios where the thread run was stuck in this function.
We assume that this lock implementation contains a deadlock bug. Therefore
this patch mock this lock with python-pthreading Lock object (which uses the
posix pthreading implementation).

Signed-off-by: Yaniv Bronhaim <ybronhei at redhat.com>
---
 pthreading.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/pthreading.py b/pthreading.py
index 916ca7f..2e9e2d6 100644
--- a/pthreading.py
+++ b/pthreading.py
@@ -127,13 +127,15 @@ class Condition(object):
 
 def monkey_patch():
     """
-    Hack threading module to use our classes
+    Hack threading and thread modules to use our classes
 
     Thus, Queue and SocketServer can easily enjoy them.
     """
 
-    import threading
+    import thread
+    thread.allocate_lock = Lock
 
+    import threading
     threading.Condition = Condition
     threading.Lock = Lock
     threading.RLock = RLock
-- 
1.8.5.3



More information about the vdsm-devel mailing list