Split up the updating of service status and serving requests into two threads.

This commit is contained in:
2025-08-29 21:39:04 +02:00
parent ce811eae7e
commit d7a118931b
4 changed files with 51 additions and 96 deletions

24
poll_services.py Normal file
View File

@@ -0,0 +1,24 @@
from mem import services
import requests
import urllib3
import time
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
def update_services() -> None:
print("Updating Service Status")
while True:
for s in services:
try:
r = requests.head(
url=s.url,
verify=s.public,
allow_redirects=True,
timeout=1,
)
s.set_status(r.ok)
except requests.exceptions.RequestException as e:
print(e)
s.set_status(False)
time.sleep(3)