Reserving image before uploading
This commit is contained in:
@@ -304,6 +304,19 @@ class LazyPluggable(object):
|
|||||||
return getattr(backend, key)
|
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):
|
class LoopingCall(object):
|
||||||
def __init__(self, f=None, *args, **kw):
|
def __init__(self, f=None, *args, **kw):
|
||||||
self.args = args
|
self.args = args
|
||||||
@@ -322,12 +335,15 @@ class LoopingCall(object):
|
|||||||
while self._running:
|
while self._running:
|
||||||
self.f(*self.args, **self.kw)
|
self.f(*self.args, **self.kw)
|
||||||
greenthread.sleep(interval)
|
greenthread.sleep(interval)
|
||||||
|
except LoopingCallDone, e:
|
||||||
|
self.stop()
|
||||||
|
done.send(e.retvalue)
|
||||||
except Exception:
|
except Exception:
|
||||||
logging.exception('in looping call')
|
logging.exception('in looping call')
|
||||||
done.send_exception(*sys.exc_info())
|
done.send_exception(*sys.exc_info())
|
||||||
return
|
return
|
||||||
|
else:
|
||||||
done.send(True)
|
done.send(True)
|
||||||
|
|
||||||
self.done = done
|
self.done = done
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user