Fix signalreceiver when switching between daemons

This commit is contained in:
Andrew Resch 2008-07-28 12:02:01 +00:00
parent 8597110e02
commit 7128b129d4
2 changed files with 5 additions and 7 deletions

View File

@ -48,10 +48,9 @@ class Signals(component.Component):
self.config.save()
def start(self):
if not client.is_localhost():
self.receiver.set_remote(True)
self.receiver.set_remote(not client.is_localhost())
self.receiver.run()
self.receiver.connect_to_signal("torrent_added",
self.torrent_added_signal)
self.receiver.connect_to_signal("torrent_removed",
@ -83,7 +82,7 @@ class Signals(component.Component):
self.receiver.shutdown()
except:
pass
def connect_to_signal(self, signal, callback):
"""Connects a callback to a signal"""
self.receiver.connect_to_signal(signal, callback)

View File

@ -51,7 +51,6 @@ class SignalReceiver(ThreadingMixIn, SimpleXMLRPCServer.SimpleXMLRPCServer):
def __init__(self):
log.debug("SignalReceiver init..")
# Set to true so that the receiver thread will exit
self._shutdown = False
self.signals = {}
self.emitted_signals = []
@ -89,6 +88,7 @@ class SignalReceiver(ThreadingMixIn, SimpleXMLRPCServer.SimpleXMLRPCServer):
def shutdown(self):
"""Shutdowns receiver thread"""
log.debug("Shutting down signalreceiver")
self._shutdown = True
# De-register with the daemon so it doesn't try to send us more signals
try:
@ -96,8 +96,6 @@ class SignalReceiver(ThreadingMixIn, SimpleXMLRPCServer.SimpleXMLRPCServer):
client.force_call()
except Exception, e:
log.debug("Unable to deregister client from server: %s", e)
log.debug("Shutting down signalreceiver")
self.socket.shutdown(socket.SHUT_RDWR)
log.debug("Joining listening thread..")
@ -111,6 +109,7 @@ class SignalReceiver(ThreadingMixIn, SimpleXMLRPCServer.SimpleXMLRPCServer):
def run(self):
"""This gets called when we start the thread"""
# Register the signal receiver with the core
self._shutdown = False
client.register_client(str(self.port))
self.listening_thread = threading.Thread(target=self.handle_thread)