utils.py 文件源码

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

项目:glare 作者: openstack 项目源码 文件源码
def wait_for_fork(pid,
                  raise_error=True,
                  expected_exitcode=0):
    """Wait for a process to complete

    This function will wait for the given pid to complete.  If the
    exit code does not match that of the expected_exitcode an error
    is raised.
    """

    rc = 0
    try:
        (pid, rc) = os.waitpid(pid, 0)
        rc = os.WEXITSTATUS(rc)
        if rc != expected_exitcode:
            raise RuntimeError('The exit code %d is not %d'
                               % (rc, expected_exitcode))
    except Exception:
        if raise_error:
            raise

    return rc
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号