async def check_read(stream, num_bytes):
    """Read bytes from an async stream and check for EOF.

    This detects EOF by getting back 0 bytes from the read, which Python defines as EOF.

    Parameters
    ----------
    stream : file-like object, async compatible
        Stream to read from
    num_bytes : int
        Number of bytes to read
    """
    data = await stream.readexactly(num_bytes)
    if data:
        return data
    raise EOFError('Got 0 byte read.')