Always start transactions on an existing path.

Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
This commit is contained in:
cl349@firebug.cl.cam.ac.uk committed 2005-09-09 16:06:04 +00:00
1 parent e295af6f75
commit 9763103317
1 file changed
+12 -2
+12 -2
View File
@@ -4,6 +4,7 @@
# Public License. See the file "COPYING" in the main directory of
# this archive for more details.
import errno
import threading
from xen.lowlevel import xs
@@ -18,9 +19,18 @@ def xshandle():
class xstransact:
def __init__(self, path):
self.in_transaction = False
self.path = path.rstrip("/")
xshandle().transaction_start(path)
self.in_transaction = True
while True:
try:
xshandle().transaction_start(path)
self.in_transaction = True
return
except RuntimeError, ex:
if ex.args[0] == errno.ENOENT and path != "/":
path = "/".join(path.split("/")[0:-1]) or "/"
else:
raise
def __del__(self):
if self.in_transaction:
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.