11import asyncio
22import os
33import signal
4- import time
4+ import traceback
5+ from dotenv import load_dotenv
56
67from dotenv import load_dotenv
78from src .macrostrat import get_macrostrat_data
@@ -19,7 +20,7 @@ def get_env_var(name: str, timeout: int = 30) -> str:
1920 for _ in range (timeout ):
2021 value = os .getenv (name )
2122 if value :
22- print (f"[DEBUG] { name } found: { value } " )
23+ print (f"[DEBUG] { name } found" )
2324 return value
2425 print (f"[DEBUG] Waiting for environment variable { name } ..." )
2526 time .sleep (1 )
@@ -30,21 +31,21 @@ def get_env_var(name: str, timeout: int = 30) -> str:
3031
3132async def periodic_task (stop_event : asyncio .Event , db_url : str , mariadb_url : str ):
3233 while not stop_event .is_set ():
34+ print ("[DEBUG] Starting periodic data fetch" )
3335 try :
34- # Pass MARIADB_URL if get_rockd_data needs it
3536 await get_rockd_data (mariadb_url , db_url )
36-
37- # Pass DATABASE_URL if get_macrostrat_data needs it
37+ print ("[DEBUG] Finished get_rockd_data" )
3838 await get_macrostrat_data (mariadb_url , db_url )
39- except Exception as e :
40- print (f"Error in periodic_task: { e } " )
39+ print ("[DEBUG] Finished get_macrostrat_data" )
40+ except Exception :
41+ print ("Error in periodic_task:" , flush = True )
42+ traceback .print_exc ()
4143
4244 try :
43- await asyncio .wait_for (stop_event .wait (), timeout = 10 )
45+ await asyncio .wait_for (stop_event .wait (), timeout = 30 )
4446 except asyncio .TimeoutError :
4547 pass
4648
47-
4849async def main ():
4950 stop_event = asyncio .Event ()
5051 # Fetch environment variables once at startup
0 commit comments