Evitar error de conexión abortada

This commit is contained in:
Your Name
2024-09-13 15:01:40 -06:00
parent ff344e8cd6
commit fc5c6379b5

11
app.py
View File

@@ -12,6 +12,10 @@ from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import StaleElementReferenceException from selenium.common.exceptions import StaleElementReferenceException
import requests
from urllib3.exceptions import ProtocolError
from http.client import RemoteDisconnected
import os import os
from flask import Flask, request, jsonify from flask import Flask, request, jsonify
from waitress import serve from waitress import serve
@@ -167,7 +171,14 @@ def extract(driver, username: str, password: str):
print("Data extracted successfully") print("Data extracted successfully")
return json_result return json_result
except (requests.exceptions.ConnectionError, ProtocolError, RemoteDisconnected) as e:
# Catch the connection errors specifically and log them but don't stop the operation
print(f"Connection issue encountered: {e}. Continuing normal operations...")
# Don't call update_alumno_extraccion_error to avoid logging this error in the database
return None # Optionally return None or a specific message
except Exception as e: except Exception as e:
# Handle all other exceptions and log them
update_alumno_extraccion_error(username_integer, str(e)) update_alumno_extraccion_error(username_integer, str(e))