MCPcopy
hub / github.com/tornadoweb/tornado / _try_inline_read

Method _try_inline_read

tornado/iostream.py:823–843  ·  view source on GitHub ↗

Attempt to complete the current read operation from buffered data. If the read can be completed without blocking, schedules the read callback on the next IOLoop iteration; otherwise starts listening for reads on the socket.

(self)

Source from the content-addressed store, hash-verified

821 self._maybe_add_error_listener()
822
823 def _try_inline_read(self) -> None:
824 """Attempt to complete the current read operation from buffered data.
825
826 If the read can be completed without blocking, schedules the
827 read callback on the next IOLoop iteration; otherwise starts
828 listening for reads on the socket.
829 """
830 # See if we've already got the data from a previous read
831 pos = self._find_read_pos()
832 if pos is not None:
833 self._read_from_buffer(pos)
834 return
835 self._check_closed()
836 pos = self._read_to_buffer_loop()
837 if pos is not None:
838 self._read_from_buffer(pos)
839 return
840 # We couldn't satisfy the read inline, so make sure we're
841 # listening for new data unless the stream is closed.
842 if not self.closed():
843 self._add_io_state(ioloop.IOLoop.READ)
844
845 def _read_to_buffer(self) -> Optional[int]:
846 """Reads from the socket and appends the result to the read buffer.

Callers 5

read_until_regexMethod · 0.95
read_untilMethod · 0.95
read_bytesMethod · 0.95
read_intoMethod · 0.95
read_until_closeMethod · 0.95

Calls 6

_find_read_posMethod · 0.95
_read_from_bufferMethod · 0.95
_check_closedMethod · 0.95
_read_to_buffer_loopMethod · 0.95
closedMethod · 0.95
_add_io_stateMethod · 0.95

Tested by

no test coverage detected