ping.py 文件源码

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

项目:stepler 作者: Mirantis 项目源码 文件源码
def _local_ping(self, count):
        cmd = self._prepare_cmd(count)
        p = subprocess.Popen(cmd,
                             stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE)
        # check that process is alive
        if p.poll() is not None:
            stdout, stderr = p.communicate()
            raise Exception(
                'Command {!r} unexpectedly exit with message {}'.format(
                    cmd, stdout, stderr))
        result = PingResult()
        yield result
        if count:
            p.wait()
        # Check if process still alive
        elif p.poll() is None:
            p.send_signal(signal.SIGINT)
        stdout, stderr = p.communicate()
        result.stdout = stdout
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号