From fc5c6379b587a5320fec0e1e68e8a98f143481e2 Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 13 Sep 2024 15:01:40 -0600 Subject: [PATCH] =?UTF-8?q?Evitar=20error=20de=20conexi=C3=B3n=20abortada?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app.py b/app.py index 5c87caa..00692f6 100644 --- a/app.py +++ b/app.py @@ -12,6 +12,10 @@ from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.common.exceptions import StaleElementReferenceException +import requests +from urllib3.exceptions import ProtocolError +from http.client import RemoteDisconnected + import os from flask import Flask, request, jsonify from waitress import serve @@ -167,7 +171,14 @@ def extract(driver, username: str, password: str): print("Data extracted successfully") 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: + # Handle all other exceptions and log them update_alumno_extraccion_error(username_integer, str(e))