Check Lua subprocess before trying to interact with it.

This commit is contained in:
Brandon Amos 2015-10-29 08:35:44 -04:00
parent 7bd9405a74
commit 1ab061d23d
1 changed files with 3 additions and 3 deletions

View File

@ -45,13 +45,14 @@ class TorchWrap:
if self.p.poll() is None: if self.p.poll() is None:
self.p.kill() self.p.kill()
atexit.register(exitHandler) atexit.register(exitHandler)
time.sleep(0.5)
def forwardPath(self, imgPath):
rc = self.p.poll() rc = self.p.poll()
if rc is not None and rc != 0: if rc is not None and rc != 0:
raise Exception(""" raise Exception("""
OpenFace: Unable to initialize the `openface_server.lua` subprocess. OpenFace: `openface_server.lua` subprocess has died.
Is the Torch command `th` on your PATH? Check with `which th`. Is the Torch command `th` on your PATH? Check with `which th`.
Diagnostic information: Diagnostic information:
@ -67,7 +68,6 @@ stdout: {}
stderr: {} stderr: {}
""".format(cmd, self.p.stdout.read(), self.p.stderr.read())) """.format(cmd, self.p.stdout.read(), self.p.stderr.read()))
def forwardPath(self, imgPath):
self.p.stdin.write(imgPath + "\n") self.p.stdin.write(imgPath + "\n")
output = self.p.stdout.readline() output = self.p.stdout.readline()
try: try: