From ddfec4e41a6d5bcfea6cc06d66b5a0ee208d7b30 Mon Sep 17 00:00:00 2001 From: Icemap Date: Mon, 24 Jun 2024 16:29:15 +0800 Subject: [PATCH] feat: open loop --- app/service/__init__.py | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/app/service/__init__.py b/app/service/__init__.py index efae907..8ff216d 100644 --- a/app/service/__init__.py +++ b/app/service/__init__.py @@ -21,23 +21,23 @@ logger = getLogger(__name__) -# -# def thread_loop(): -# while True: -# try: -# incremental_loop() -# except Exception as e: -# logger.error(f"[Error {datetime.datetime.now()}] translate_or_update_first_page() {e}") -# -# if conf.sleep_time != 0: -# time.sleep(conf.sleep_time) -# -# -# def incremental_loop(): -# translate_or_update_first_page() -# -# -# thread = threading.Thread(target=thread_loop) -# thread.setDaemon(True) -# thread.start() -# logger.info(f"Sync task is running now.") + +def thread_loop(): + while True: + try: + incremental_loop() + except Exception as e: + logger.error(f"[Error {datetime.datetime.now()}] translate_or_update_first_page() {e}") + + if conf.sleep_time != 0: + time.sleep(conf.sleep_time) + + +def incremental_loop(): + translate_or_update_first_page() + + +thread = threading.Thread(target=thread_loop) +thread.setDaemon(True) +thread.start() +logger.info(f"Sync task is running now.")