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

Method _start_read

tornado/iostream.py:785–806  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

783 self._read_from_buffer(pos)
784
785 def _start_read(self) -> Future:
786 if self._read_future is not None:
787 # It is an error to start a read while a prior read is unresolved.
788 # However, if the prior read is unresolved because the stream was
789 # closed without satisfying it, it's better to raise
790 # StreamClosedError instead of AssertionError. In particular, this
791 # situation occurs in harmless situations in http1connection.py and
792 # an AssertionError would be logged noisily.
793 #
794 # On the other hand, it is legal to start a new read while the
795 # stream is closed, in case the read can be satisfied from the
796 # read buffer. So we only want to check the closed status of the
797 # stream if we need to decide what kind of error to raise for
798 # "already reading".
799 #
800 # These conditions have proven difficult to test; we have no
801 # unittests that reliably verify this behavior so be careful
802 # when making changes here. See #2651 and #2719.
803 self._check_closed()
804 assert self._read_future is None, "Already reading"
805 self._read_future = Future()
806 return self._read_future
807
808 def _finish_read(self, size: int) -> None:
809 if self._user_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 1

_check_closedMethod · 0.95

Tested by

no test coverage detected