本文整理匯總了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)