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
评论列表
文章目录