From 8bcfbb807034af230b01a14cdbb65fc73fd7e166 Mon Sep 17 00:00:00 2001 From: Roel Date: Thu, 21 May 2015 16:02:37 +0200 Subject: [PATCH] added exception handling to announce() --- main.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index 878204d..c92827f 100755 --- a/main.py +++ b/main.py @@ -122,10 +122,13 @@ Announce the node's existance to other nodes """ logger.info('Announcing') while not self.exitapp: - sock = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM, socket.IPPROTO_UDP) - sock.sendto(self.index_last_update, ("ff02::1", self.announce_port)) - sock.close() - time.sleep(5) + try: + sock = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM, socket.IPPROTO_UDP) + sock.sendto(self.index_last_update, ("ff02::1", self.announce_port)) + #sock.close() + time.sleep(5) + except: + logger.warning('Failed to announce myself!') def discover(self): """