From 06a3afa5d67014e33110ec9208d79a01affc5262 Mon Sep 17 00:00:00 2001 From: Brandon Amos Date: Tue, 29 Sep 2015 18:03:00 -0400 Subject: [PATCH] Python library: Kill Lua subprocess on exit. --- facenet/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/facenet/__init__.py b/facenet/__init__.py index e42c27b..d2ec20a 100644 --- a/facenet/__init__.py +++ b/facenet/__init__.py @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import atexit from subprocess import Popen, PIPE import os.path @@ -29,6 +30,7 @@ class TorchWrap: if cuda: cmd.append('-cuda') self.p = Popen(cmd, stdin=PIPE, stdout=PIPE, bufsize=0) + atexit.register(self.p.kill) def forward(self, imgPath): self.p.stdin.write(imgPath+"\n")