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

Method read_until

python/python3/tornado/iostream.py:368–401  ·  view source on GitHub ↗

Asynchronously read until we have found the given delimiter. The result includes all the data read including the delimiter. If ``max_bytes`` is not None, the connection will be closed if more than ``max_bytes`` bytes have been read and the delimiter is not found.

(
        self, delimiter: bytes, max_bytes: Optional[int] = None
    )

Source from the content-addressed store, hash-verified

366 return future
367
368 def read_until(
369 self, delimiter: bytes, max_bytes: Optional[int] = None
370 ) -> Awaitable[bytes]:
371 """Asynchronously read until we have found the given delimiter.
372
373 The result includes all the data read including the delimiter.
374
375 If ``max_bytes`` is not None, the connection will be closed
376 if more than ``max_bytes`` bytes have been read and the delimiter
377 is not found.
378
379 .. versionchanged:: 4.0
380 Added the ``max_bytes`` argument. The ``callback`` argument is
381 now optional and a `.Future` will be returned if it is omitted.
382
383 .. versionchanged:: 6.0
384
385 The ``callback`` argument was removed. Use the returned
386 `.Future` instead.
387 """
388 future = self._start_read()
389 self._read_delimiter = delimiter
390 self._read_max_bytes = max_bytes
391 try:
392 self._try_inline_read()
393 except UnsatisfiableReadError as e:
394 # Handle this the same way as in _handle_events.
395 gen_log.info("Unsatisfiable read, closing connection: %s" % e)
396 self.close(exc_info=e)
397 return future
398 except:
399 future.add_done_callback(lambda f: f.exception())
400 raise
401 return future
402
403 def read_bytes(self, num_bytes: int, partial: bool = False) -> Awaitable[bytes]:
404 """Asynchronously read a number of bytes.

Callers 15

_read_chunked_bodyMethod · 0.80
test_subprocessMethod · 0.80
test_close_stdinMethod · 0.80
test_stderrMethod · 0.80
accept_callbackMethod · 0.80
handle_streamMethod · 0.80
capitalizeMethod · 0.80
test_future_interfaceMethod · 0.80
test_large_read_untilMethod · 0.80

Calls 4

_start_readMethod · 0.95
_try_inline_readMethod · 0.95
closeMethod · 0.95
infoMethod · 0.80