def _sender(self): "поток отправляющий ответы из очереди" try: while not self._stop_event.is_set(): client_name, response = self._responses.get() if client_name in self.clients: sock = self.clients[client_name].outsock try: send(sock, response) except socket_error as error: print_log('sender error', str(error)) print_log('sender stop') except Exception as error: print_log('snder', error) self._handle_exception(*exc_info())
def handle_write(self): "отправляет ответы серверу из очереди" if self.out_messages: for message in self.out_messages: send(self.outsock, message) self.out_messages = []