Changes for small performance things
This commit is contained in:
parent
63d23a4c8a
commit
05b99203b1
3 changed files with 25 additions and 5 deletions
|
@ -75,6 +75,8 @@ class CentralCommand(object):
|
||||||
|
|
||||||
self.timer = Stopwatch()
|
self.timer = Stopwatch()
|
||||||
|
|
||||||
|
self.hugveyWarnings = {}
|
||||||
|
|
||||||
eventLogger.addHandler(logging.handlers.QueueHandler(self.logQueue))
|
eventLogger.addHandler(logging.handlers.QueueHandler(self.logQueue))
|
||||||
|
|
||||||
def loadConfig(self, filename):
|
def loadConfig(self, filename):
|
||||||
|
@ -160,6 +162,8 @@ class CentralCommand(object):
|
||||||
status['has_state'] = Story.hugveyHasSavedState(hv.lightId)
|
status['has_state'] = Story.hugveyHasSavedState(hv.lightId)
|
||||||
status['variables'] = {} if not isSelected or not hv.story else hv.story.variableValues
|
status['variables'] = {} if not isSelected or not hv.story else hv.story.variableValues
|
||||||
|
|
||||||
|
# evLogger = eventLogger.getChild(f"{hv_id}")
|
||||||
|
|
||||||
if not hv.story:
|
if not hv.story:
|
||||||
status['time_since_hugvey_spoke'] = '-'
|
status['time_since_hugvey_spoke'] = '-'
|
||||||
status['time_since_visitor_spoke'] = '-'
|
status['time_since_visitor_spoke'] = '-'
|
||||||
|
@ -169,12 +173,28 @@ class CentralCommand(object):
|
||||||
elif not hasattr(hv.story, 'lastMsgFinishTime') or not hv.story.lastMsgFinishTime:
|
elif not hasattr(hv.story, 'lastMsgFinishTime') or not hv.story.lastMsgFinishTime:
|
||||||
status['time_since_hugvey_spoke'] = 'speaking'
|
status['time_since_hugvey_spoke'] = 'speaking'
|
||||||
else:
|
else:
|
||||||
status['time_since_hugvey_spoke'] = str(datetime.timedelta(seconds=int(hv.story.timer.getElapsed() - hv.story.lastMsgFinishTime)))
|
diff = datetime.timedelta(seconds=int(hv.story.timer.getElapsed() - hv.story.lastMsgFinishTime))
|
||||||
|
status['time_since_hugvey_spoke'] = str(diff)
|
||||||
|
# if diff > 300:
|
||||||
|
# evLogger.warning("Very long time since hugvey spoke")
|
||||||
|
# elif diff > 100:
|
||||||
|
# evLogger.warning("Long time since hugvey spoke")
|
||||||
|
# else:
|
||||||
|
# #clear warning
|
||||||
|
# pass
|
||||||
|
|
||||||
if not hv.story.timer.hasMark('last_speech'):
|
if not hv.story.timer.hasMark('last_speech'):
|
||||||
status['time_since_visitor_spoke'] = 'never'
|
status['time_since_visitor_spoke'] = 'never'
|
||||||
else:
|
else:
|
||||||
status['time_since_visitor_spoke'] = str(datetime.timedelta(seconds=int(hv.story.timer.getElapsed('last_speech'))))
|
diff = datetime.timedelta(seconds=int(hv.story.timer.getElapsed('last_speech')))
|
||||||
|
status['time_since_visitor_spoke'] = str(diff)
|
||||||
|
# if diff > 300:
|
||||||
|
# evLogger.warning("Very long time since audience spoke")
|
||||||
|
# elif diff > 100:
|
||||||
|
# evLogger.warning("Long time since audience spoke")
|
||||||
|
# else:
|
||||||
|
# #clear warning
|
||||||
|
# pass
|
||||||
|
|
||||||
return status
|
return status
|
||||||
|
|
||||||
|
|
|
@ -2016,7 +2016,7 @@ class Story(object):
|
||||||
@classmethod
|
@classmethod
|
||||||
def getStateDir(self):
|
def getStateDir(self):
|
||||||
# return "/tmp"
|
# return "/tmp"
|
||||||
return "./recordings"
|
return "./state"
|
||||||
# day = time.strftime("%Y%m%d")
|
# day = time.strftime("%Y%m%d")
|
||||||
# t = time.strftime("%H:%M:%S")
|
# t = time.strftime("%H:%M:%S")
|
||||||
#
|
#
|
||||||
|
|
|
@ -42,8 +42,8 @@ if __name__ == '__main__':
|
||||||
logger = logging.getLogger("hugvey")
|
logger = logging.getLogger("hugvey")
|
||||||
|
|
||||||
logFileHandler = logging.handlers.RotatingFileHandler(
|
logFileHandler = logging.handlers.RotatingFileHandler(
|
||||||
'./recordings/server.log',
|
'./state/server.log',
|
||||||
maxBytes=1024*512,
|
maxBytes=1024*5120,
|
||||||
backupCount=5
|
backupCount=5
|
||||||
)
|
)
|
||||||
logFileHandler.setFormatter(logging.Formatter(
|
logFileHandler.setFormatter(logging.Formatter(
|
||||||
|
|
Loading…
Reference in a new issue