def run(self):
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)<EOL>sock.bind(self._addr)<EOL>sock.settimeout(self._timeout)<EOL>with closing(sock):<EOL><INDENT>while not self._shutdown.is_set():<EOL><INDENT>try:<EOL><INDENT>data, addr = sock.recvfrom(self._buffer_size)<EOL><DEDENT>except socket.timeout:<EOL><INDENT>continue<EOL><DEDENT>header, rest = parse_packet(data)<EOL>if header.packet_type in _PAYLOADS:<EOL><INDENT>payload = parse_payload(rest,<EOL>*_PAYLOADS[header.packet_type])<EOL>self._callbacks.put(header.packet_type,<EOL>header, payload, None, addr)<EOL><DEDENT>else:<EOL><INDENT>self._callbacks.put(EVENT_UNKNOWN,<EOL>header, None, rest, addr)<EOL><DEDENT><DEDENT><DEDENT>
Process all incoming packets, until `stop()` is called. Intended to run
in its own thread.