markov: Add some more log messages
Nothing major, just more log messages. Signed-off-by: Alek Ratzloff <alekratz@gmail.com>
This commit is contained in:
@@ -57,11 +57,11 @@ class Chain:
|
|||||||
return
|
return
|
||||||
self.__touch()
|
self.__touch()
|
||||||
self.__load()
|
self.__load()
|
||||||
|
self.__dirty = True
|
||||||
for fragment in windows(parts + [None], self.order + 1):
|
for fragment in windows(parts + [None], self.order + 1):
|
||||||
head = fragment[0:-1]
|
head = fragment[0:-1]
|
||||||
tail = fragment[-1]
|
tail = fragment[-1]
|
||||||
self.__cache[" ".join(head)][tail] += 1
|
self.__cache[" ".join(head)][tail] += 1
|
||||||
self.__dirty = True
|
|
||||||
|
|
||||||
def get(self, key: str) -> dict[str | None, int]:
|
def get(self, key: str) -> dict[str | None, int]:
|
||||||
if self.__cache:
|
if self.__cache:
|
||||||
@@ -131,6 +131,8 @@ class Chain:
|
|||||||
with open(self.path, "w") as fp:
|
with open(self.path, "w") as fp:
|
||||||
json.dump(obj, fp)
|
json.dump(obj, fp)
|
||||||
self.__dirty = False
|
self.__dirty = False
|
||||||
|
else:
|
||||||
|
log.info("Chain %s is not dirty, not saving", self.path)
|
||||||
|
|
||||||
def clear_cache(self):
|
def clear_cache(self):
|
||||||
self.__cache.clear()
|
self.__cache.clear()
|
||||||
@@ -257,7 +259,7 @@ class Markov(Plugin):
|
|||||||
|
|
||||||
async def __save_loop(self):
|
async def __save_loop(self):
|
||||||
while True:
|
while True:
|
||||||
log.debug("Pruning inactive markov chains in %s seconds", self.save_every)
|
log.debug("Saving markov chains in %s seconds", self.save_every)
|
||||||
await asyncio.sleep(self.save_every)
|
await asyncio.sleep(self.save_every)
|
||||||
retain_after = asyncio.get_running_loop().time() - self.save_every
|
retain_after = asyncio.get_running_loop().time() - self.save_every
|
||||||
await self.save(retain_after=retain_after)
|
await self.save(retain_after=retain_after)
|
||||||
@@ -277,6 +279,7 @@ class Markov(Plugin):
|
|||||||
for chains in self.__chains.values():
|
for chains in self.__chains.values():
|
||||||
for chain in chains.values():
|
for chain in chains.values():
|
||||||
# Start the save in a new process, in a new task.
|
# Start the save in a new process, in a new task.
|
||||||
|
log.debug("Starting process to save %s", chain.path)
|
||||||
coro = loop.run_in_executor(pool, chain.save)
|
coro = loop.run_in_executor(pool, chain.save)
|
||||||
coros += [coro]
|
coros += [coro]
|
||||||
# Prune
|
# Prune
|
||||||
|
|||||||
Reference in New Issue
Block a user