mirror of https://gitlab.com/bashrc2/epicyon
Loading and saving fitness metrics
parent
4f38fd4e29
commit
2bd1bef5b4
10
daemon.py
10
daemon.py
|
@ -347,6 +347,7 @@ from context import getIndividualPostContext
|
|||
from speaker import getSSMLbox
|
||||
from city import getSpoofedCity
|
||||
from fitnessFunctions import fitnessPerformance
|
||||
from fitnessFunctions import fitnessThread
|
||||
import os
|
||||
|
||||
|
||||
|
@ -16917,7 +16918,10 @@ def runDaemon(defaultReplyIntervalHours: int,
|
|||
assert not scanThemesForScripts(baseDir)
|
||||
|
||||
# fitness metrics
|
||||
fitnessFilename = baseDir + '/accounts/fitness.json'
|
||||
httpd.fitness = {}
|
||||
if os.path.isfile(fitnessFilename):
|
||||
httpd.fitness = loadJson(fitnessFilename)
|
||||
|
||||
# initialize authorized fetch key
|
||||
httpd.signingPrivateKeyPem = None
|
||||
|
@ -17223,6 +17227,12 @@ def runDaemon(defaultReplyIntervalHours: int,
|
|||
print('Creating shared item files directory')
|
||||
os.mkdir(baseDir + '/sharefiles')
|
||||
|
||||
print('Creating fitness thread')
|
||||
httpd.thrFitness = \
|
||||
threadWithTrace(target=fitnessThread,
|
||||
args=(baseDir, httpd.fitness), daemon=True)
|
||||
httpd.thrFitness.start()
|
||||
|
||||
print('Creating cache expiry thread')
|
||||
httpd.thrCache = \
|
||||
threadWithTrace(target=expireCache,
|
||||
|
|
|
@ -8,6 +8,7 @@ __status__ = "Production"
|
|||
__module_group__ = "Core"
|
||||
|
||||
import time
|
||||
from utils import saveJson
|
||||
|
||||
|
||||
def fitnessPerformance(startTime, fitnessState: {},
|
||||
|
@ -37,3 +38,13 @@ def fitnessPerformance(startTime, fitnessState: {},
|
|||
print('FITNESS: performance/' + fitnessId + '/' +
|
||||
watchPoint + '/' +
|
||||
str(fitnessState['performance'][fitnessId][watchPoint]))
|
||||
|
||||
|
||||
def fitnessThread(baseDir: str, fitness: {}):
|
||||
"""Thread used to save fitness function scores
|
||||
"""
|
||||
fitnessFilename = baseDir + '/accounts/fitness.json'
|
||||
while True:
|
||||
# every 10 mins
|
||||
time.sleep(60 * 10)
|
||||
saveJson(fitness, fitnessFilename)
|
||||
|
|
Loading…
Reference in New Issue