当前位置: 首页>>代码示例>>Python>>正文


Python Timer.setCurrentDateAndTime方法代码示例

本文整理汇总了Python中Timer.setCurrentDateAndTime方法的典型用法代码示例。如果您正苦于以下问题:Python Timer.setCurrentDateAndTime方法的具体用法?Python Timer.setCurrentDateAndTime怎么用?Python Timer.setCurrentDateAndTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Timer的用法示例。


在下文中一共展示了Timer.setCurrentDateAndTime方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: start

# 需要导入模块: import Timer [as 别名]
# 或者: from Timer import setCurrentDateAndTime [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)
开发者ID:timewizhan,项目名称:MSProject,代码行数:80,代码来源:Scheduler.py


注:本文中的Timer.setCurrentDateAndTime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。