Python方法oslo_service.loopingcall.LoopingCallDone代码示例
Python方法oslo_service.loopingcall.LoopingCallDone代码示例
demo:
from oslo_service import loopingcall def _wait_for_image_state(): global num num = 0 def _wait_for_state(): global num print num num = num + 1 if num == 10: raise loopingcall.LoopingCallDone() timer = loopingcall.FixedIntervalLoopingCall(_wait_for_state) timer.start(interval=0.5).wait() _wait_for_image_state()
测试结果:
[root@localhost ~]# python loopingcall.py 0 1 2 3 4 5 6 7 8 9