Exemple #1
0
    def _queue_command(self, cmd):
        """Queue the command until the connection is ready to write to again."""
        logger.debug("[%s] Queueing as conn %r, cmd: %r", self.id(), self.state, cmd)
        self.pending_commands.append(cmd)

        if len(self.pending_commands) > self.max_line_buffer:
            # The other side is failing to keep up and out buffers are becoming
            # full, so lets close the connection.
            # XXX: should we squawk more loudly?
            logger.error("[%s] Remote failed to keep up", self.id())
            self.send_command(ErrorCommand("Failed to keep up"), do_buffer=False)
            self.close()
Exemple #2
0
 def send_error(self, error_string, *args):
     """Send an error to remote and close the connection."""
     self.send_command(ErrorCommand(error_string % args))
     self.close()