Can block on network if request is larger than send_buffer_bytes
965854
def send_pending_requests(self):
        """"""
        try:
            with self._lock:
                if not self._can_send_recv():
                    return Errors.NodeNotReadyError(str(self))
                # In the future we might manage an internal write buffer
                # and send bytes asynchronously. For now, just block
                # sending each request payload
                data = self._protocol.send_bytes()
                total_bytes = self._send_bytes_blocking(data)
            if self._sensors:
                self._sensors.bytes_sent.record(total_bytes)
            return total_bytes
        except ConnectionError as e:
            log.exception("Error sending request data to %s", self)
            error = Errors.KafkaConnectionError("%s: %s" % (self, e))
            self.close(error=error)
            return error
113339
def safe_send(self, connection, target, message, *args, **kwargs):
        
        # Compute maximum length of payload
        prefix = "PRIVMSG {0} :".format(target)
        max_len = 510 - len(prefix)

        for chunk in chunks(message.format(*args, **kwargs), max_len):
            connection.send_raw("{0}{1}".format(prefix, chunk))
42898
def sendDAT(self):
        """"""
        finished = False
        blocknumber = self.context.next_block
        # Test hook
        if DELAY_BLOCK and DELAY_BLOCK == blocknumber:
            import time
            log.debug("Deliberately delaying 10 seconds...")
            time.sleep(10)
        dat = None
        blksize = self.context.getBlocksize()
        buffer = self.context.fileobj.read(blksize)
        log.debug("Read %d bytes into buffer", len(buffer))
        if len(buffer) < blksize:
            log.info("Reached EOF on file %s"
                % self.context.file_to_transfer)
            finished = True
        dat = TftpPacketDAT()
        dat.data = buffer
        dat.blocknumber = blocknumber
        self.context.metrics.bytes += len(dat.data)
        log.debug("Sending DAT packet %d", dat.blocknumber)
        self.context.sock.sendto(dat.encode().buffer,
                                 (self.context.host, self.context.tidport))
        if self.context.packethook:
            self.context.packethook(dat)
        self.context.last_pkt = dat
        return finished
538305
def content_size_exceeded_max(self, content_bytes):
        '''
        
        '''
        content_size = sys.getsizeof(content_bytes)
        if content_size > self.item_size_max():
            return (True, content_size)

        return (False, content_size)
1342065
def _handle_request_noblock(self):
        

        try:
            request, client_address = self.get_request()
        except socket.error:
            return

        if self.verify_request(request, client_address):
            try:
                self.process_request(request, client_address)
            except:
                self.handle_error(request, client_address)
                self.shutdown_request(request)
203760
def _recv(sock, size):
    """"""
    while True:
        try:
            return sock.recv(size)
        except IOError as e:
            if e.errno != errno.EINTR:
                raise
309247
def _send_size(self):
        "  "
        rows, cols = _get_size(sys.stdout.fileno())
        self._send_packet({
            'cmd': 'size',
            'data': [rows, cols]
        })
419649
def recv(self, size):
        
        try:
            buffer = b""
            start = time.time()
            while len(buffer) < size:
                select_timeout = None
                if self.timeout is not None:
                    elapsed = time.time() - start
                    if elapsed >= self.timeout:
                        raise socket.timeout()
                    select_timeout = self.timeout - elapsed

                r, w, x = select([self.process.stdout], [], [], select_timeout)
                if r and r[0] == self.process.stdout:
                    buffer += os.read(
                        self.process.stdout.fileno(), size - len(buffer)
                    )
            return buffer
        except socket.timeout:
            if buffer:
                # Don't raise socket.timeout, return partial result instead
                return buffer
            raise  # socket.timeout is a subclass of IOError
        except IOError as e:
            raise ProxyCommandFailure(" ".join(self.cmd), e.strerror)
935210
async def _send(self, request_bytes, body_bytes, h11_connection):
        '''
        
        '''
        await self.sock.send_all(h11_connection.send(request_bytes))
        if body_bytes is not None:
            await self.sock.send_all(h11_connection.send(body_bytes))
        await self.sock.send_all(h11_connection.send(h11.EndOfMessage()))
578516
public boolean bufferAckEnabled() {
    String bufSize = get(Names.CONNECTION_BUFFER_SIZE);
    return bufSize != null && Integer.parseInt(bufSize) > 0;
  }
602000
function _send_channel_packet($client_channel, $data)
    {
        while (strlen($data)) {
            if (!$this->window_size_client_to_server[$client_channel]) {
                $this->bitmap^= self::MASK_WINDOW_ADJUST;
                // using an invalid channel will let the buffers be built up for the valid channels
                $this->_get_channel_packet(-1);
                $this->bitmap^= self::MASK_WINDOW_ADJUST;
            }

            /* The maximum amount of data allowed is determined by the maximum
               packet size for the channel, and the current window size, whichever
               is smaller.
                 -- http://tools.ietf.org/html/rfc4254#section-5.2 */
            $max_size = min(
                $this->packet_size_client_to_server[$client_channel],
                $this->window_size_client_to_server[$client_channel]
            );

            $temp = $this->_string_shift($data, $max_size);
            $packet = pack(
                'CN2a*',
                NET_SSH2_MSG_CHANNEL_DATA,
                $this->server_channels[$client_channel],
                strlen($temp),
                $temp
            );
            $this->window_size_client_to_server[$client_channel]-= strlen($temp);
            if (!$this->_send_binary_packet($packet)) {
                return false;
            }
        }

        return true;
    }
1011019
def blocking(func, *args, **kwargs):
    
    pool = get_io_pool()
    fut = pool.submit(func, *args, **kwargs)
    return fut.result()
920392
def recv(sock, size):
    """"""
    data = sock.recv(size, socket.MSG_WAITALL)
    if len(data) < size:
        raise socket.error(ECONNRESET, 'Connection closed')
    return data
693343
protected void onBlock(ConnectionFilter filter, String remoteAddr,
			int connections, int requests, int bytes) {
		filter.disconnect();
		filter.onDisconnect();
	}
1308206
def send_data(self):
        """"""
        if not self.connection._sock:
            raise err.InterfaceError("(0, '')")
        conn = self.connection

        try:
            with open(self.filename, 'rb') as open_file:
                packet_size = min(conn.max_allowed_packet, 16*1024)  # 16KB is efficient enough
                while True:
                    chunk = open_file.read(packet_size)
                    if not chunk:
                        break
                    conn.write_packet(chunk)
        except IOError:
            raise err.OperationalError(1017, "Can't find file '{0}'".format(self.filename))
        finally:
            # send the empty packet to signify we are done sending data
            conn.write_packet(b'')
919425
def _pad_bytes(request_bytes):
    

    padding_length = (_BLOCK_SIZE - len(request_bytes) % _BLOCK_SIZE)
    padding_character = bytes(bytearray([padding_length]))

    return request_bytes + padding_character * padding_length
705914
def nonblock_recv(self):
        """"""
        self.ins.setnonblock(1)
        p = self.recv(MTU)
        self.ins.setnonblock(0)
        return p