Sfoglia il codice sorgente

🎉 feat: add time_out as an env variable

this is about to have access to time out when starting container
metya 2 anni fa
parent
commit
7b13f72f3a
4 ha cambiato i file con 7 aggiunte e 2 eliminazioni
  1. 2 0
      docker/Dockerfile
  2. 1 0
      docker/compose.yaml
  3. 1 0
      src/config.py
  4. 3 2
      src/dialog.py

+ 2 - 0
docker/Dockerfile

@@ -4,6 +4,8 @@ ENV PIP_NO_CACHE_DIR=off \
     PIP_DISABLE_PIP_VERSION_CHECK=on
 ARG API_TOKEN
 ARG GITHUB_TOKEN
+ARG TIME_OUT
+ENV TIME_OUT=$TIME_OUT
 ENV GITHUB_TOKEN=$GITHUB_TOKEN
 ENV API_TOKEN=$API_TOKEN
 

+ 1 - 0
docker/compose.yaml

@@ -9,4 +9,5 @@ services:
     environment:
       - API_TOKEN
       - GITHUB_TOKEN
+      - TIME_OUT
     restart: always

+ 1 - 0
src/config.py

@@ -5,6 +5,7 @@ if env_var := dotenv_values('misc/token'):
     API_TOKEN = env_var["API_TOKEN"]
 else:
     API_TOKEN = getenv("API_TOKEN")
+    TIME_OUT = getenv("TIME_OUT")
 
 if __name__ == "__main__":
     print(API_TOKEN)

+ 3 - 2
src/dialog.py

@@ -10,7 +10,7 @@ from aiogram_dialog.widgets.text import Format
 from aiogram.types import ParseMode
 
 from src.summarize import get_summary
-
+from src.config import TIME_OUT
 from src.progress import Bg, background
 
 warn = "***Note, that it is an AI generated summary, and it may contain complete bullshit***"
@@ -33,7 +33,8 @@ buttons = [
     ]
 
 
-async def time_out_dialog(manager: BaseDialogManager, widget: Any, time_out: int = 1200):
+async def time_out_dialog(manager: BaseDialogManager, widget: Any, time_out: int|str|None = TIME_OUT):
+    time_out = int(time_out) if time_out else 1800
     for _ in range(time_out):
         await sleep(1)
     await manager.update({"final_state": "1"})