fix: use event instead of chained timer for daemon

Old solution causes amount of thread to be growing as well as stack is
increased during each iteration. Instead of cycle-free implementation,
this commit just uses while cycle
This commit is contained in:
2023-11-30 13:40:59 +02:00
parent 0991dbb59c
commit acc204de6d
2 changed files with 23 additions and 9 deletions

View File

@ -43,8 +43,10 @@ class Daemon(Handler):
report(bool): force enable or disable reporting
"""
from ahriman.application.handlers import Update
Update.run(args, repository_id, configuration, report=report)
timer = threading.Timer(args.interval, Daemon.run, args=[args, repository_id, configuration],
kwargs={"report": report})
timer.start()
timer.join()
event = threading.Event()
try:
while not event.wait(args.interval):
Update.run(args, repository_id, configuration, report=report)
except KeyboardInterrupt:
pass # normal exit