feat: Program interrupt key quit

This commit is contained in:
kbe
2025-07-20 03:12:22 +02:00
parent cba4299b9a
commit 4b27a6f4a3

View File

@@ -15,7 +15,7 @@ from dateutil.parser import parse
import pytz
from dotenv import load_dotenv
from urllib.parse import urlencode
from typing import List, Dict, Optional
from typing import List, Dict, Optional, Any
load_dotenv()
@@ -474,6 +474,7 @@ class CrossFitBooker:
logging.error("Authentication failed - exiting program")
return
try:
while True:
try:
current_time: datetime = datetime.now(tz)
@@ -491,6 +492,16 @@ class CrossFitBooker:
except Exception as e:
logging.error(f"Unexpected error in booking cycle: {str(e)} - Traceback: {traceback.format_exc()}")
time.sleep(60) # Wait before retrying after error
except KeyboardInterrupt:
self.quit()
def quit(self) -> None:
"""
Clean up resources and exit the script.
"""
logging.info("Script interrupted by user. Quitting...")
# Add any cleanup code here
exit(0)
if __name__ == "__main__":
@@ -501,3 +512,5 @@ if __name__ == "__main__":
# Start continuous booking loop
booker.run()
logging.info("Script completed")