def _iterations_until(self, completed, update_state, argument):
""" Poll for a state change to complete callable-s
:param completed: A callable accepting argument, returning true if the
state change has successfully completed.
:param update_state: The action to execute in order to poll for a state
change
:param argument: The arguments on which to execute both the check and
the action. Probably a tuple.
:return: The number of iterations taken
:rtype: int
"""
if completed(*argument):
return 0
s = scheduler(time.time, time.sleep)
i = 0
started_at = time.time()
while not completed(*argument) and not self._has_timed_out(started_at):
delta = max(0, min(self._poll,
self._timeout - (time.time() - started_at)))
s.enter(delta, 0, update_state, argument)
s.run()
i += 1
return i
digitalocean_flocker_plugin.py 文件源码
python
阅读 21
收藏 0
点赞 0
评论 0
评论列表
文章目录