本文整理汇总了Python中Time.sleep方法的典型用法代码示例。如果您正苦于以下问题:Python Time.sleep方法的具体用法?Python Time.sleep怎么用?Python Time.sleep使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Time
的用法示例。
在下文中一共展示了Time.sleep方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: startDose
# 需要导入模块: import Time [as 别名]
# 或者: from Time import sleep [as 别名]
def startDose(doseLength, waitTime):
if(shouldDose == True):
doseLock = True
t0 = Utility.currentTimeMillis()
#set dig output pin to start dosing
try:
ik.interfaceKit.setOutputState(0, 1)
except PhidgetException as e:
doseLock = False
ik.interfaceKit.setOutputState(0, 0)
print("Phidget Exception %i: %s" % (e.code, e.details))
print("Exiting....")
exit(1)
print("setting dig output to 1")
# dose until the dose time is met or something else releases the lock
while((Utility.currentTimeMillis() - t0) < timeToDose * 1000 or doseLock != True):
Time.sleep(0.1)
try:
ik.interfaceKit.setOutputState(0, 0)
doseLock = False
print("dosed for %i second out put changed to 0" % (timeToDose))
except PhidgetException as e:
doseLock = False
print("Phidget Exception %i: %s" % (e.code, e.details))
print("Exiting....")
exit(1)
doseLock = False