本文整理汇总了Python中Logging.event方法的典型用法代码示例。如果您正苦于以下问题:Python Logging.event方法的具体用法?Python Logging.event怎么用?Python Logging.event使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Logging
的用法示例。
在下文中一共展示了Logging.event方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: resetTimer
# 需要导入模块: import Logging [as 别名]
# 或者: from Logging import event [as 别名]
def resetTimer(self, initial = False):
if self.timerObj:
self.timerObj.cancel() #Does not care if timer is alive
#if initial will try to set it to the firstTime today
if initial:
self.nextTrigger = self.firstTime
else:
self.nextTrigger = self.nextTrigger + self.timedelta
if self.nextTrigger < datetime.now(): #If the trigger is in the past
raise ValueError("Next PeriodicUpdater is in the past! \nDelta: "+repr(self.timedelta)+" nextTrigger: " + repr(self.nextTrigger))
log.event("Setting new trigger for", str(self.nextTrigger))
#Express the difference in time between the next trigger and now as an integer for the timer to wait
difference = int((self.nextTrigger - datetime.now()).total_seconds())+1 #+1 because it rounds down to 23 hours 59 mins, 59 seconds
log.event.debug("Trigger will fire in",str(timedelta(seconds = difference)))
#First stop tracking this one
deregisterThread(self.timerObj)
del self.timerObj
#And track the next one once it is made
self.timerObj = threading.Timer(difference, self.startFunction)
registerThread(self.timerObj)
self.timerObj.daemon = True #We don't want this thread blocking system exit
self.timerObj.start() #Starts the timer
示例2: startFunction
# 需要导入模块: import Logging [as 别名]
# 或者: from Logging import event [as 别名]
def startFunction(self):
log.event("PeriodicUpdater acquiring thread to run function")
lock = getLockObject()
lock.acquire() #Wait for whatever other function is executing now to finish
try:
self.function(*self.arg, **self.kwarg)
finally: #Whether or not it errors we need to release the lock and reset the function
lock.release()
self.resetTimer() #Sets the next iteration
示例3: saveAll
# 需要导入模块: import Logging [as 别名]
# 或者: from Logging import event [as 别名]
def saveAll(self, final = False):
try:
if len(self._objects): # if != 0
log.event("Saving all messages for",len(self._objects),"group"+("s" if len(self._objects) > 1 else ""))
while len(self._objects): #While there are still objects in the list
object = self._objects.pop() #Take it off and use it
object._save() #_save must be a function that DOES NOT CALL addObject
finally: #Whether or not we are successful, add another timer
if not final:
self.resetTimer()
示例4: stopAllTimers
# 需要导入模块: import Logging [as 别名]
# 或者: from Logging import event [as 别名]
def stopAllTimers():
log.event("Stopping all timers")
for thread in _threadList:
thread.cancel()