Commit b44a83b1 authored by Gottfried Gaisbauer's avatar Gottfried Gaisbauer
Browse files

improved errorhandling

parent 96451cf0
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import sys
import time
import socket
import urllib.parse
import configparser
import logging
from io import StringIO
from multiprocessing import Lock
from libraries.exceptions.auraexceptions import LQConnectionError
......@@ -54,9 +50,11 @@ class LiquidSoapClient:
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
self.socket.connect(self.socket_path)
except socket.error as e:
msg = "Cannot connect to socketpath " + self.socket_path + ". Reason: "+str(e)
self.logger.critical(msg)
self.can_connect = False
self.connected = False
raise e
# raise e
else:
self.can_connect = True
self.connected = True
......
......@@ -28,6 +28,7 @@ class LiquidSoapCommunicator(ExceptionLogger):
error_data = None
auramailer = None
aborttransaction = False
connection_attempts = 0
# ------------------------------------------------------------------------------------------ #
def __init__(self, config):
......@@ -1019,15 +1020,20 @@ class LiquidSoapCommunicator(ExceptionLogger):
# say byebye if needed
#if self.transaction == 0:
# self.__close_conn(lqs_instance)
self.connection_attempts = 0
return result
except LQConnectionError as e:
if self.try_to_reconnect():
return self.__send_lqc_command__(lqs_instance, namespace, command, *args)
self.connection_attempts += 1
if self.connection_attempts < 5:
return self.__send_lqc_command__(lqs_instance, namespace, command, *args)
else:
raise e
else:
# also store when was last admin mail sent with which content...
self.logger.warning("SEND ADMIN MAIL AT THIS POINT")
self.logger.critical("SEND ADMIN MAIL AT THIS POINT")
raise e
# ------------------------------------------------------------------------------------------ #
......
Supports Markdown
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