MCPcopy Create free account
hub / github.com/EasyIME/PIME / _read_to_buffer_loop

Method _read_to_buffer_loop

python/python3/tornado/iostream.py:737–776  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

735 raise
736
737 def _read_to_buffer_loop(self) -> Optional[int]:
738 # This method is called from _handle_read and _try_inline_read.
739 if self._read_bytes is not None:
740 target_bytes = self._read_bytes # type: Optional[int]
741 elif self._read_max_bytes is not None:
742 target_bytes = self._read_max_bytes
743 elif self.reading():
744 # For read_until without max_bytes, or
745 # read_until_close, read as much as we can before
746 # scanning for the delimiter.
747 target_bytes = None
748 else:
749 target_bytes = 0
750 next_find_pos = 0
751 while not self.closed():
752 # Read from the socket until we get EWOULDBLOCK or equivalent.
753 # SSL sockets do some internal buffering, and if the data is
754 # sitting in the SSL object's buffer select() and friends
755 # can't see it; the only way to find out if it's there is to
756 # try to read it.
757 if self._read_to_buffer() == 0:
758 break
759
760 # If we've read all the bytes we can use, break out of
761 # this loop.
762
763 # If we've reached target_bytes, we know we're done.
764 if target_bytes is not None and self._read_buffer_size >= target_bytes:
765 break
766
767 # Otherwise, we need to call the more expensive find_read_pos.
768 # It's inefficient to do this on every read, so instead
769 # do it on the first read and whenever the read buffer
770 # size has doubled.
771 if self._read_buffer_size >= next_find_pos:
772 pos = self._find_read_pos()
773 if pos is not None:
774 return pos
775 next_find_pos = self._read_buffer_size * 2
776 return self._find_read_pos()
777
778 def _handle_read(self) -> None:
779 try:

Callers 2

_handle_readMethod · 0.95
_try_inline_readMethod · 0.95

Calls 4

readingMethod · 0.95
closedMethod · 0.95
_read_to_bufferMethod · 0.95
_find_read_posMethod · 0.95

Tested by

no test coverage detected