def close(self):
# Errors from closing pipes or wait4() are unlikely, but possible.
# Ideally would give up waiting after a while and forcibly terminate the
# subprocess.
errors = []
try:
self.command_pipe.close()
except EnvironmentError, e:
errors.append("error closing command pipe:\n%s" % e)
try:
self.response_pipe.close()
except EnvironmentError, e:
errors.append("error closing response pipe:\n%s" % e)
errors.append(str(e))
try:
# We don't really care about the exit status, but we do want to be
# sure it isn't still running.
# Even if there were errors closing the pipes, it's most likely that
# the subprocesses has exited.
pid, exit_status, rusage = os.wait4(self.subprocess.pid, 0)
self.exit_status = exit_status
self.resource_usage = rusage
except EnvironmentError, e:
errors.append(str(e))
if errors:
raise GtpTransportError("\n".join(errors))
评论列表
文章目录