From f4edfba532835f32328063d355dec289f5d95321 Mon Sep 17 00:00:00 2001 From: Egg Date: Wed, 9 Oct 2024 16:14:29 +0200 Subject: [PATCH] add timer for bot crawl that appears in debug log --- backend.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/backend.py b/backend.py index d3f0778..223fbcc 100755 --- a/backend.py +++ b/backend.py @@ -5,7 +5,7 @@ from config import config from db import db import logging from sendmail import sendmail -from time import sleep +from time import sleep, time def shutdown(): try: @@ -34,14 +34,16 @@ if __name__ == '__main__': while True: sleep(15) # rest 15 seconds between each crawl run for user in db.active_users: + sleep(1) for bot in bots: + timer_crawl = time() reports = bot.crawl(user) + logger.debug("Crawl using bot %s took %f seconds" % (bot, time()-timer_crawl)) for status in reports: if not user.is_appropriate(status): logger.info("Inaproppriate message: %d %s %s" % (user.uid, status.author, status.text)) continue for bot2 in bots: - sleep(1) bot2.post(user, status) logger.info("Resent: %d %s %s" % (user.uid, status.author, status.text)) except Exception: