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

Method read_bytes

python/python3/tornado/iostream.py:403–429  ·  view source on GitHub ↗

Asynchronously read a number of bytes. If ``partial`` is true, data is returned as soon as we have any bytes to return (but never more than ``num_bytes``) .. versionchanged:: 4.0 Added the ``partial`` argument. The callback argument is now optional

(self, num_bytes: int, partial: bool = False)

Source from the content-addressed store, hash-verified

401 return future
402
403 def read_bytes(self, num_bytes: int, partial: bool = False) -> Awaitable[bytes]:
404 """Asynchronously read a number of bytes.
405
406 If ``partial`` is true, data is returned as soon as we have
407 any bytes to return (but never more than ``num_bytes``)
408
409 .. versionchanged:: 4.0
410 Added the ``partial`` argument. The callback argument is now
411 optional and a `.Future` will be returned if it is omitted.
412
413 .. versionchanged:: 6.0
414
415 The ``callback`` and ``streaming_callback`` arguments have
416 been removed. Use the returned `.Future` (and
417 ``partial=True`` for ``streaming_callback``) instead.
418
419 """
420 future = self._start_read()
421 assert isinstance(num_bytes, numbers.Integral)
422 self._read_bytes = num_bytes
423 self._read_partial = partial
424 try:
425 self._try_inline_read()
426 except:
427 future.add_done_callback(lambda f: f.exception())
428 raise
429 return future
430
431 def read_into(self, buf: bytearray, partial: bool = False) -> Awaitable[int]:
432 """Asynchronously read a number of bytes.

Calls 2

_start_readMethod · 0.95
_try_inline_readMethod · 0.95