Do not try to send signals to a client after 30 consecutive failures.
This commit is contained in:
parent
885ca2c899
commit
e554140276
|
@ -43,10 +43,10 @@ class SignalManager(component.Component):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
component.Component.__init__(self, "SignalManager")
|
component.Component.__init__(self, "SignalManager")
|
||||||
self.clients = {}
|
self.clients = {}
|
||||||
|
|
||||||
def shutdown(self):
|
def shutdown(self):
|
||||||
del self.clients
|
del self.clients
|
||||||
|
|
||||||
def deregister_client(self, address):
|
def deregister_client(self, address):
|
||||||
"""Deregisters a client"""
|
"""Deregisters a client"""
|
||||||
log.debug("Deregistering %s as a signal reciever..", address)
|
log.debug("Deregistering %s as a signal reciever..", address)
|
||||||
|
@ -60,14 +60,20 @@ class SignalManager(component.Component):
|
||||||
uri = "http://" + str(address) + ":" + str(port)
|
uri = "http://" + str(address) + ":" + str(port)
|
||||||
log.debug("Registering %s as a signal reciever..", uri)
|
log.debug("Registering %s as a signal reciever..", uri)
|
||||||
self.clients[uri] = xmlrpclib.ServerProxy(uri)
|
self.clients[uri] = xmlrpclib.ServerProxy(uri)
|
||||||
|
|
||||||
def emit(self, signal, *data):
|
def emit(self, signal, *data):
|
||||||
for client in self.clients.values():
|
for uri in self.clients:
|
||||||
gobject.idle_add(self._emit, client, signal, *data)
|
gobject.idle_add(self._emit, uri, signal, 1, *data)
|
||||||
|
|
||||||
def _emit(self, client, signal, *data):
|
def _emit(self, uri, signal, count, *data):
|
||||||
|
client = self.clients[uri]
|
||||||
try:
|
try:
|
||||||
client.emit_signal(signal, *data)
|
client.emit_signal(signal, *data)
|
||||||
except (socket.error, Exception), e:
|
except (socket.error, Exception), e:
|
||||||
log.warning("Unable to emit signal to client %s: %s", client, e)
|
log.warning("Unable to emit signal to client %s: %s (%d)", client, e, count)
|
||||||
|
if count < 30:
|
||||||
|
gobject.timeout_add(1000, self._emit, uri, signal, count + 1, *data)
|
||||||
|
else:
|
||||||
|
log.info("Removing %s because it couldn't be reached..", uri)
|
||||||
|
del self.clients[uri]
|
||||||
|
|
||||||
|
|
|
@ -135,7 +135,7 @@ class SignalReceiver(
|
||||||
log.warning("Unable to call callback for signal %s",
|
log.warning("Unable to call callback for signal %s",
|
||||||
signal)
|
signal)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
log.debug("There are no callbacks registered for this signal..")
|
log.debug("There are no callbacks registered for signal '%s'", signal)
|
||||||
|
|
||||||
def connect_to_signal(self, signal, callback):
|
def connect_to_signal(self, signal, callback):
|
||||||
"""Connect to a signal"""
|
"""Connect to a signal"""
|
||||||
|
|
Loading…
Reference in New Issue