def run(self):
while True:<EOL><INDENT>to_send = self._queue.get()<EOL>if to_send is _SHUTDOWN:<EOL><INDENT>break<EOL><DEDENT>if isinstance(to_send, Gateway):<EOL><INDENT>self._gateway = to_send<EOL>self._connected.set()<EOL><DEDENT>else:<EOL><INDENT>if not self._gateway:<EOL><INDENT>raise SendException('<STR_LIT>')<EOL><DEDENT>dest = (self._gateway.addr, self._gateway.port)<EOL>sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)<EOL>sock.sendto(to_send, dest)<EOL><DEDENT><DEDENT>
Process all outgoing packets, until `stop()` is called. Intended to run
in its own thread.