CoolFace
Apppublic

fvps/loop

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
keep_alive.py24 linesDownload Raw Back to root
1# keep_alive.py2import time3from curl_cffi import requests4import os5import threading6 7def function_to_run():8    count = 09    url = f"{os.environ.get('PROJECT_DOMAIN')}/health"10    while True:11        if count > 30:12            break13        try:14            requests.get(url)15            print("Keeping alive...")16        except:17            print("Failed to keep alive")18            count += 119        time.sleep(int(os.environ.get('SLEEPSECOND', 100)))20 21thread = threading.Thread(target=function_to_run)22thread.start()23# thread.join()24