Commit 18e7ce35 authored by Erly Villaroel's avatar Erly Villaroel

timeout

parent 6fa897ba
......@@ -6,7 +6,7 @@ from flask import request, jsonify
from config import Config as cfg
from app.main.engine.enum.StatusEnum import StatusEnum
from app.main.engine.service.EngineService import EngineService
from wrapt_timeout_decorator import *
class MainController:
......@@ -33,9 +33,25 @@ class MainController:
try:
self.executions += 1
descriptor = request.get_json()
service = EngineService(self.app, descriptor, self.executions, self.max_executions)
response = service.run()
tiempo_limite = descriptor["config-params"]["max-timeout-per-combinations"]
@timeout(tiempo_limite)
def procesamiento():
response = {}
try:
response = EngineService(self.app, descriptor, self.executions, self.max_executions).run()
except Exception as e:
response["statusCode"] = StatusEnum.ERROR.name
response["error"] = {"message": "", "detail": str(e)}
raise TimeoutError(f"Tiempo límite de ejecución superado{e}")
finally:
return response
response = procesamiento()
self.app.logger.info(response)
except TimeoutError as e:
self.app.logger.error(f"Error al superar timeout. {e}")
response["statusCode"] = StatusEnum.ERROR.name
response["error"] = {"message": "", "detail": str(e)}
except Exception as e:
self.app.logger.error(f"Error en el envío del parser al servicio. {e}")
response["statusCode"] = StatusEnum.ERROR.name
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment