本文整理汇总了Python中service.Service.onUpdate方法的典型用法代码示例。如果您正苦于以下问题:Python Service.onUpdate方法的具体用法?Python Service.onUpdate怎么用?Python Service.onUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类service.Service
的用法示例。
在下文中一共展示了Service.onUpdate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: onUpdate
# 需要导入模块: from service import Service [as 别名]
# 或者: from service.Service import onUpdate [as 别名]
def onUpdate(self):
"""This is called periodically from run()"""
if not Service.onUpdate(self):
return False
t = time.time()
for addr, subscriptions in self.subscribers.iteritems():
for clientData in subscriptions:
if clientData.nextSendTime != None and t >= clientData.nextSendTime:
value = self.getPath(clientData.path)
if len(subscriptions) == 1:
self.numOutMessages += 1
clientData.client.sendMessage(value)
else:
self.numOutMessages += 1
clientData.client.sendMessage({"path": "." + path, "data": value})
clientData.nextSendTime += 1.0 / clientData.rate
self.timeOutMessageProcess += time.time() - t
if self.numInMessages > 1000:
# print self.numInMessages,"incoming messages, processing time",self.timeInMessageProcess/self.numInMessages
self.numInMessages = 0
self.timeInMessageProcess = 0
if self.numOutMessages > 1000:
# print self.numOutMessages,"outgoing messages, processing time",self.timeOutMessageProcess/self.numOutMessages
self.numOutMessages = 0
self.timeOutMessageProcess = 0
return True