def read_bytes_from_buffer(n: int, buffer: BinaryIO) -> bytes:
"""Reads n bytes from stdin, blocking until all bytes are received.
Parameters
----------
n
How many bytes to read.
buffer
Which buffer to read from.
Returns
-------
bytes
Exactly n bytes.
"""
b = b''
while len(b) < n:
b += buffer.read(n - len(b))
assert len(b) == n
return b
评论列表
文章目录