Long-running socket watcher, needs proper cleanup

This commit is contained in:
James Barnsley
2018-11-04 14:41:08 +13:00
parent 4327771b2e
commit ffaef9d63e
8 changed files with 156 additions and 44 deletions

View File

@ -8,6 +8,8 @@ logger = logging.getLogger(__name__)
class IrisSnapcastThread(Thread):
sock = None
def __init__(self, config, broadcast):
Thread.__init__(self)
self.config = config
@ -19,7 +21,12 @@ class IrisSnapcastThread(Thread):
##
def run(self):
socket = IrisSnapcast(self.config)
socket.connect()
socket.listen(self.broadcast)
self.sock = IrisSnapcast(self.config)
self.sock.listen(self.broadcast)
##
# Instruction to stop this thread
##
def close(self):
self.sock.stop_listening()