parameters: (self)
return_statement: return None
docstring: Attempts to find a position in the read buffer that satisfies
          the currently-pending read.
  
          Returns a position in the buffer if the current read can be satisfied,
          or None if it cannot.
docstring_summary: Attempts to find a position in the read buffer that satisfies
          the currently-pending read.
docstring_tokens: Attempts to find a position in the read buffer that satisfies the currently - pending read .
function: def _find_read_pos(self) -> Optional[int]:
          """Attempts to find a position in the read buffer that satisfies
          the currently-pending read.
  
          Returns a position in the buffer if the current read can be satisfied,
          or None if it cannot.
          """
          if self._read_bytes is not None and (
              self._read_buffer_size >= self._read_bytes
              or (self._read_partial and self._read_buffer_size > 0)
          ):
              num_bytes = min(self._read_bytes, self._read_buffer_size)
              return num_bytes
          elif self._read_delimiter is not None:
              # Multi-byte delimiters (e.g. '\r\n') may straddle two
              # chunks in the read buffer, so we can't easily find them
              # without collapsing the buffer.  However, since protocols
              # using delimited reads (as opposed to reads of a known
              # length) tend to be "line" oriented, the delimiter is likely
              # to be in the first few chunks.  Merge the buffer gradually
              # since large merges are relatively expensive and get undone in
              # _consume().
              if self._read_buffer:
                  loc = self._read_buffer.find(
                      self._read_delimiter, self._read_buffer_pos
                  )
                  if loc != -1:
                      loc -= self._read_buffer_pos
                      delimiter_len = len(self._read_delimiter)
                      self._check_max_bytes(self._read_delimiter, loc + delimiter_len)
                      return loc + delimiter_len
                  self._check_max_bytes(self._read_delimiter, self._read_buffer_size)
          elif self._read_regex is not None:
              if self._read_buffer:
                  m = self._read_regex.search(self._read_buffer, self._read_buffer_pos)
                  if m is not None:
                      loc = m.end() - self._read_buffer_pos
                      self._check_max_bytes(self._read_regex, loc)
                      return loc
                  self._check_max_bytes(self._read_regex, self._read_buffer_size)
          return None
function_tokens: def _find_read_pos ( self ) -> Optional [ int ] : if self . _read_bytes is not None and ( self . _read_buffer_size >= self . _read_bytes or ( self . _read_partial and self . _read_buffer_size > 0 ) ) : num_bytes = min ( self . _read_bytes , self . _read_buffer_size ) return num_bytes elif self . _read_delimiter is not None : # Multi-byte delimiters (e.g. '\r\n') may straddle two # chunks in the read buffer, so we can't easily find them # without collapsing the buffer.  However, since protocols # using delimited reads (as opposed to reads of a known # length) tend to be "line" oriented, the delimiter is likely # to be in the first few chunks.  Merge the buffer gradually # since large merges are relatively expensive and get undone in # _consume(). if self . _read_buffer : loc = self . _read_buffer . find ( self . _read_delimiter , self . _read_buffer_pos ) if loc != - 1 : loc -= self . _read_buffer_pos delimiter_len = len ( self . _read_delimiter ) self . _check_max_bytes ( self . _read_delimiter , loc + delimiter_len ) return loc + delimiter_len self . _check_max_bytes ( self . _read_delimiter , self . _read_buffer_size ) elif self . _read_regex is not None : if self . _read_buffer : m = self . _read_regex . search ( self . _read_buffer , self . _read_buffer_pos ) if m is not None : loc = m . end ( ) - self . _read_buffer_pos self . _check_max_bytes ( self . _read_regex , loc ) return loc self . _check_max_bytes ( self . _read_regex , self . _read_buffer_size ) return None