summaryrefslogtreecommitdiffstats
path: root/nova/utils.py
diff options
context:
space:
mode:
authorRick Harris <rick.harris@rackspace.com>2011-01-06 21:37:33 -0600
committerRick Harris <rick.harris@rackspace.com>2011-01-06 21:37:33 -0600
commit3bf9bc6f6c0fbf90e3f4eab68a9bd99d85fcc422 (patch)
treefb87ea36fb400d76698d498319d8e95092f258d7 /nova/utils.py
parentdd1e36b9690a2c2de18c565c496b25295a13d0aa (diff)
downloadnova-3bf9bc6f6c0fbf90e3f4eab68a9bd99d85fcc422.tar.gz
nova-3bf9bc6f6c0fbf90e3f4eab68a9bd99d85fcc422.tar.xz
nova-3bf9bc6f6c0fbf90e3f4eab68a9bd99d85fcc422.zip
Reserving image before uploading
Diffstat (limited to 'nova/utils.py')
-rw-r--r--nova/utils.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/nova/utils.py b/nova/utils.py
index 15112faa2..8d3bf0a6b 100644
--- a/nova/utils.py
+++ b/nova/utils.py
@@ -304,6 +304,19 @@ class LazyPluggable(object):
return getattr(backend, key)
+class LoopingCallDone(Exception):
+ """The poll-function passed to LoopingCall can raise this exception to
+ break out of the loop normally. This is somewhat analogous to StopIteration.
+
+ An optional return-value can be included as the argument to the exception;
+ this return-value will be returned by LoopingCall.wait()
+ """
+
+ def __init__(self, retvalue=True):
+ """:param retvalue: Value that LoopingCall.wait() should return"""
+ self.retvalue = retvalue
+
+
class LoopingCall(object):
def __init__(self, f=None, *args, **kw):
self.args = args
@@ -322,12 +335,15 @@ class LoopingCall(object):
while self._running:
self.f(*self.args, **self.kw)
greenthread.sleep(interval)
+ except LoopingCallDone, e:
+ self.stop()
+ done.send(e.retvalue)
except Exception:
logging.exception('in looping call')
done.send_exception(*sys.exc_info())
return
-
- done.send(True)
+ else:
+ done.send(True)
self.done = done