WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] Add gather function and robustify class methods' failure

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Add gather function and robustify class methods' failure handling.
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 14 Sep 2005 19:58:10 +0000
Delivery-date: Wed, 14 Sep 2005 19:56:38 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User cl349@xxxxxxxxxxxxxxxxxxxx
# Node ID eb6fbb3d0a7b1bde4546957314b12ed3557b1d71
# Parent  9c9a3bb878c2c1c9cc932cbc90335ad701b0e009
Add gather function and robustify class methods' failure handling.
Signed-off-by: Christian Limpach <Christian.Limpach@xxxxxxxxxxxx>

diff -r 9c9a3bb878c2 -r eb6fbb3d0a7b 
tools/python/xen/xend/xenstore/xstransact.py
--- a/tools/python/xen/xend/xenstore/xstransact.py      Wed Sep 14 17:06:37 2005
+++ b/tools/python/xen/xend/xenstore/xstransact.py      Wed Sep 14 18:24:25 2005
@@ -106,6 +106,23 @@
             ret.extend(self._list(key))
         return ret
 
+    def gather(self, *args):
+        ret = []
+        for tup in args:
+            if len(tup) == 2:
+                (key, fn) = tup
+                defval = None
+            else:
+                (key, fn, defval) = tup
+            try:
+                val = fn(self.read(key))
+            except TypeError:
+                val = defval
+            ret.append(val)
+        if len(ret) == 1:
+            return ret[0]
+        return ret
+
 
     def Read(cls, path, *args):
         while True:
@@ -115,10 +132,14 @@
                 t.commit()
                 return v
             except RuntimeError, ex:
-                if ex.args[0] == errno.ETIMEDOUT:
-                    pass
-                else:
-                    raise
+                t.abort()
+                if ex.args[0] == errno.ETIMEDOUT:
+                    pass
+                else:
+                    raise
+            except:
+                t.abort()
+                raise
 
     Read = classmethod(Read)
 
@@ -130,10 +151,14 @@
                 t.commit()
                 return
             except RuntimeError, ex:
-                if ex.args[0] == errno.ETIMEDOUT:
-                    pass
-                else:
-                    raise
+                t.abort()
+                if ex.args[0] == errno.ETIMEDOUT:
+                    pass
+                else:
+                    raise
+            except:
+                t.abort()
+                raise
 
     Write = classmethod(Write)
 
@@ -145,10 +170,14 @@
                 t.commit()
                 return
             except RuntimeError, ex:
-                if ex.args[0] == errno.ETIMEDOUT:
-                    pass
-                else:
-                    raise
+                t.abort()
+                if ex.args[0] == errno.ETIMEDOUT:
+                    pass
+                else:
+                    raise
+            except:
+                t.abort()
+                raise
 
     Remove = classmethod(Remove)
 
@@ -160,9 +189,32 @@
                 t.commit()
                 return v
             except RuntimeError, ex:
-                if ex.args[0] == errno.ETIMEDOUT:
-                    pass
-                else:
-                    raise
+                t.abort()
+                if ex.args[0] == errno.ETIMEDOUT:
+                    pass
+                else:
+                    raise
+            except:
+                t.abort()
+                raise
 
     List = classmethod(List)
+
+    def Gather(cls, path, *args):
+        while True:
+            try:
+                t = cls(path)
+                v = t.gather(*args)
+                t.commit()
+                return v
+            except RuntimeError, ex:
+                t.abort()
+                if ex.args[0] == errno.ETIMEDOUT:
+                    pass
+                else:
+                    raise
+            except:
+                t.abort()
+                raise
+
+    Gather = classmethod(Gather)

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Add gather function and robustify class methods' failure handling., Xen patchbot -unstable <=