Move files to folders

This commit is contained in:
Lucas Mathews
2024-06-07 19:12:22 +02:00
parent 21fe74853c
commit 2be3ccb830
13 changed files with 1808 additions and 0 deletions

33
server/scheduler.py Normal file
View File

@@ -0,0 +1,33 @@
# Lucas Mathews - Fontys Student ID: 5023572
# Banking System Scheduler
import threading
import schedule
import time
from manager import log_event
stop_event = threading.Event()
def run_schedule():
while not stop_event.is_set():
schedule.run_pending()
time.sleep(1) # Add a short sleep to reduce CPU usage
def clean_otp():
"""Cleans the OTP table."""
print("Cleaning OTPs...")
from manager import clean_expired_otps
removed_otps = clean_expired_otps()
log_event(f"Removed {removed_otps} expired OTPs.")
schedule.every(300).seconds.do(clean_otp)
thread = threading.Thread(target=run_schedule)
thread.daemon = True # Set the thread as a daemon thread
thread.start()
try:
while True: # Keep the main program running
time.sleep(1)
except KeyboardInterrupt:
stop_event.set() # Signal the thread to stop