code: def listen(self, timeout=10):
          
          self._socket.settimeout(float(timeout))
          while not self.stopped.isSet():
              try:
                  data, client_address = self._socket.recvfrom(4096)
              except socket.timeout:
                  continue
              try:
  
                  self.receive_datagram((data, client_address))
              except RuntimeError:
                  logger.exception("Exception with Executor")
          self._socket.close()
docs: Listen for incoming messages. Timeout is used to check if the server must be switched off.
  
          :param timeout: Socket Timeout in seconds