本文整理汇总了Python中Timer.getWaitTimeForNextHour方法的典型用法代码示例。如果您正苦于以下问题:Python Timer.getWaitTimeForNextHour方法的具体用法?Python Timer.getWaitTimeForNextHour怎么用?Python Timer.getWaitTimeForNextHour使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Timer
的用法示例。
在下文中一共展示了Timer.getWaitTimeForNextHour方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: start
# 需要导入模块: import Timer [as 别名]
# 或者: from Timer import getWaitTimeForNextHour [as 别名]
def start(self):
from Log import *
Log.debug("Start scheduler")
timer = Timer()
timer.setCurrentDateAndTime()
processID = os.getpid()
Log.debug("Start to operate bot [" + str(processID) + "]\n")
# Make a pattern
self.patternDelegator.startToGetPattern(self.jobHashMap)
Log.debug("=============================================")
Log.debug("=================== Ready ===================")
Log.debug("=============================================")
while self.continued:
try:
start = self.checkNextHour(timer)
# After generating the pattern
# Send the report to the manager
# and wait for the start message
if self.firstStep:
#Log.debug("Send the action message to the manager\n")
#reportToSend = makeManagerJsonData(self.userID)
#recvMsgFromManager = self.networkingWithManager(reportToSend)
self.firstStep = False
#if len(recvMsgFromManager) == 0:
# Log.error("Fail to receive the action message from the manager")
# self.continued = False
# continue
if start:
Log.debug("=============================================")
Log.debug("=================== Start ===================")
Log.debug("=============================================")
currentHour = timer.getCurrentHour()
while start:
nextJobToWork = self.jobHashMap.dequeJobValueByKey(currentHour)
if nextJobToWork == 0:
start = False
Log.debug("Complete sending requests")
break
delay = random.randrange(1, 6)
time.sleep(delay)
Log.debug("Start to communicate with servers\n")
dstName = self.getDstName(nextJobToWork)
Log.debug("Start to find dstName in Hash\n")
if not self.isIncludedInHash(dstName):
dstIPAddress = self.startToCommunicationWithBroker(nextJobToWork)
self.addInHash(dstName, dstIPAddress)
if self.hash_dstIPAddress[dstName]:
self.startToCommunicateWithService(nextJobToWork, dstIPAddress)
if not self.continued:
break
Log.debug("Wait for next hour\n")
wait = timer.getWaitTimeForNextHour()
time.sleep(wait)
timer.setCurrentDateAndTime()
except Exception as e:
Log.error("There is error in scheduler")
Log.error(e)
sys.exit(1)
Log.debug("Successfully end the one day job")
sys.exit(0)