Skip to content

Commit

Permalink
Merge pull request #8 from pingcap-inc/feat-sleep-time
Browse files Browse the repository at this point in the history
feat: parameterize sleep time
  • Loading branch information
Cheese authored Jun 24, 2024
2 parents ecf6f2b + 00247d5 commit 8089978
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
1 change: 1 addition & 0 deletions app/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def __init__(self):
load_dotenv()

self.debug = bool(os.getenv("DEBUG", "True") == "True")
self.sleep_time = int(os.getenv("SLEEP_TIME", "30"))

self.open_ai_base_url = os.getenv("OPEN_AI_BASE_URL", "https://api.openai.com/v1")
self.open_ai_api = os.getenv("OPEN_AI_API", "")
Expand Down
7 changes: 3 additions & 4 deletions app/service/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@

from app.service.translate import translate_task, task_error, translate_or_update_first_page
import threading

sleep_time = 3600
from app.config import conf


def thread_loop():
Expand All @@ -27,8 +26,8 @@ def thread_loop():
except Exception as e:
print(f"[Error {datetime.datetime.now()}] translate_or_update_first_page() {e}")

if sleep_time != 0:
time.sleep(sleep_time)
if conf.sleep_time != 0:
time.sleep(conf.sleep_time)


def incremental_loop():
Expand Down

0 comments on commit 8089978

Please sign in to comment.