[vdsm] [PATCH] Monkeypatch python's thread.allocate_lock
Nir Soffer
nsoffer at redhat.com
Thu Feb 27 14:51:54 UTC 2014
----- Original Message -----
> From: "Yaniv Bronhaim" <ybronhei at redhat.com>
> To: vdsm-devel at lists.fedorahosted.org
> Sent: Thursday, February 27, 2014 3:59:27 PM
> Subject: [vdsm] [PATCH] Monkeypatch python's thread.allocate_lock
>
> 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
Mocking a locki is replacing a real lock with something which is not
a lock but looks like a lock.
Here you replace the builtin lock with pthread mutex.
+1 otherwise.
Nir
More information about the vdsm-devel
mailing list