Change in vdsm[master]: clientIF: Use a weakref.proxy when registering contEIOVMs

alitke at redhat.com alitke at redhat.com
Fri Nov 21 17:41:26 UTC 2014


Adam Litke has uploaded a new change for review.

Change subject: clientIF: Use a weakref.proxy when registering contEIOVMs
......................................................................

clientIF: Use a weakref.proxy when registering contEIOVMs

Our storage Event class is taking a weakref on the callback function
that is passed into Event.register.  Unfortunately weakrefs on bound
methods are dead on arrival.  See this [1] discussion for more
information.  Use the same approach as StoragePool._upgradeCallback and
use a weakref.proxy to build the callback function.

[1] http://code.activestate.com/recipes/81253/

Change-Id: Ib06967b26fc9ace41e5f8305a8fadafbbb0fc4e4
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1157421
Signed-off-by: Adam Litke <alitke at redhat.com>
---
M vdsm/clientIF.py
1 file changed, 4 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/36/35436/1

diff --git a/vdsm/clientIF.py b/vdsm/clientIF.py
index 79ba8f8..b339211 100644
--- a/vdsm/clientIF.py
+++ b/vdsm/clientIF.py
@@ -23,6 +23,8 @@
 import time
 import threading
 import uuid
+from functools import partial
+from weakref import proxy
 
 import alignmentScan
 from vdsm.config import config
@@ -76,7 +78,8 @@
         self._shutdownSemaphore = threading.Semaphore()
         self.irs = irs
         if self.irs:
-            self.irs.registerDomainStateChangeCallback(self.contEIOVms)
+            cb = partial(clientIF.contEIOVms, proxy(self))
+            self.irs.registerDomainStateChangeCallback(cb)
         self.log = log
         self._recovery = True
         self.channelListener = Listener(self.log)


-- 
To view, visit http://gerrit.ovirt.org/35436
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib06967b26fc9ace41e5f8305a8fadafbbb0fc4e4
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Adam Litke <alitke at redhat.com>


More information about the vdsm-patches mailing list