MCPcopy
hub / github.com/aio-libs/aiohttp / readuntil

Method readuntil

aiohttp/parsers.py:391–417  ·  view source on GitHub ↗
(self, stop, limit=None)

Source from the content-addressed store, hash-verified

389 self._writer.send((yield))
390
391 def readuntil(self, stop, limit=None):
392 assert isinstance(stop, bytes) and stop, \
393 'bytes is required: {!r}'.format(stop)
394
395 stop_len = len(stop)
396
397 while True:
398 if self._helper.exception:
399 raise self._helper.exception
400
401 pos = self._data.find(stop)
402 if pos >= 0:
403 end = pos + stop_len
404 size = end
405 if limit is not None and size > limit:
406 raise errors.LineLimitExceededParserError(
407 'Line is too long.', limit)
408
409 data = self._data[:size]
410 del self._data[:size]
411 return data
412 else:
413 if limit is not None and len(self._data) > limit:
414 raise errors.LineLimitExceededParserError(
415 'Line is too long.', limit)
416
417 self._writer.send((yield))
418
419 def wait(self, size):
420 """wait() waits for specified amount of bytes

Callers 11

__call__Method · 0.80
__call__Method · 0.80
__call__Method · 0.80
parse_chunked_payloadMethod · 0.80
LinesParserFunction · 0.80
test_readuntil_limitFunction · 0.80
test_readuntil_limit2Function · 0.80
test_readuntil_limit3Function · 0.80
test_readuntilFunction · 0.80
test_readuntil_excFunction · 0.80
my_protocol_parserFunction · 0.80

Calls 1

sendMethod · 0.45

Tested by 6

LinesParserFunction · 0.64
test_readuntil_limitFunction · 0.64
test_readuntil_limit2Function · 0.64
test_readuntil_limit3Function · 0.64
test_readuntilFunction · 0.64
test_readuntil_excFunction · 0.64