Python library: Kill Lua subprocess on exit.

This commit is contained in:
Brandon Amos 2015-09-29 18:03:00 -04:00
parent 158ff1bcce
commit 06a3afa5d6
1 changed files with 2 additions and 0 deletions

View File

@ -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")