_lowlevel.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:seaworthy 作者: praekeltfoundation 项目源码 文件源码
def read_by_deadline(resp, sock, deadline, n):
    """
    Read up to N bytes from a socket. If there's nothing to read, signal that
    it's closed.
    """
    time_left = deadline - get_time()
    # Avoid past-deadline special cases by setting a small timeout instead.
    sock.settimeout(max(time_left, 0.001))
    try:
        data = resp.raw.read(n)
    except (ReadTimeoutError, socket.timeout) as e:
        raise TimeoutError('Timeout waiting for container logs.')
    if len(data) == 0:
        raise SocketClosed()
    return data
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号