diff --git a/lib/daemon.py b/lib/daemon.py index e10f6e22c606e8c32c5998bae76a220cdab89e4f..6eca3a3ec3f18bb12d7c604c60f1b37002b53148 100644 --- a/lib/daemon.py +++ b/lib/daemon.py @@ -91,20 +91,23 @@ class AsyncUDPSocket(asyncore.dispatcher): # differ and treat all messages equally. pass + def do_read(self): + try: + payload, address = self.recvfrom(constants.MAX_UDP_DATA_SIZE) + except socket.error, err: + if err.errno == errno.EINTR: + # we got a signal while trying to read. no need to do anything, + # handle_read will be called again if there is data on the socket. + return + else: + raise + ip, port = address + self.handle_datagram(payload, ip, port) + # this method is overriding an asyncore.dispatcher method def handle_read(self): try: - try: - payload, address = self.recvfrom(constants.MAX_UDP_DATA_SIZE) - except socket.error, err: - if err.errno == errno.EINTR: - # we got a signal while trying to read. no need to do anything, - # handle_read will be called again if there is data on the socket. - return - else: - raise - ip, port = address - self.handle_datagram(payload, ip, port) + self.do_read() except: # pylint: disable-msg=W0702 # we need to catch any exception here, log it, but proceed, because even # if we failed handling a single request, we still want to continue.