'Try and write as much as we can, if we get blocked requeue
what\'s left'

def _handle_write(self):

    total_bytes_sent = 0
    try:
        while self.outbound_buffer:
            frame = self.outbound_buffer.popleft()
            while True:
                try:
                    num_bytes_sent = self.socket.send(frame)
                    break
                except _SOCKET_ERROR as error:
                    if (error.errno == errno.EINTR):
                        continue
                    else:
                        raise
            total_bytes_sent += num_bytes_sent
            if (num_bytes_sent < len(frame)):
                LOGGER.debug('Partial    write,    requeing    remaining    data')
                self.outbound_buffer.appendleft(frame[num_bytes_sent:])
                break
    except socket.timeout:
        LOGGER.debug('socket    timeout,    requeuing    frame')
        self.outbound_buffer.appendleft(frame)
        self._handle_timeout()
    except _SOCKET_ERROR as error:
        if (error.errno in (errno.EAGAIN, errno.EWOULDBLOCK)):
            LOGGER.debug('Would    block,    requeuing    frame')
            self.outbound_buffer.appendleft(frame)
        else:
            return self._handle_error(error)
    return total_bytes_sent
