-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
32 lines (26 loc) · 967 Bytes
/
main.py
File metadata and controls
32 lines (26 loc) · 967 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from pathlib import Path
import subprocess
import time
import traceback
import sys
from loguru import logger
import config
logger.add(sink="invoice_crawler.log", rotation="50 MB")
max_process_life_time = int(config.MAX_PROCESS_LIFE_TIME)
process_restart_delay_time = int(config.PROCESS_RESTART_DELAY_TIME)
parent_path = Path(__file__).parent.absolute()
while True:
try:
process = subprocess.run(
[f"{parent_path}/.venv/bin/python3.10", f"{parent_path}/pipeline.py"],
text=True,
stdout=sys.stdout,
stderr=sys.stderr,
timeout=max_process_life_time,
)
logger.info(f"process exit status: {process.returncode}")
except Exception as e:
logger.info(f"exception on last main.py round \n traceback: {traceback.format_exc()}")
finally:
logger.info(f"going for next round after {process_restart_delay_time} sec")
time.sleep(process_restart_delay_time)