From 088c89dfd061cc1dfa4d69df3d7f793dc91f3169 Mon Sep 17 00:00:00 2001 From: nobu-g Date: Fri, 8 Oct 2021 16:47:28 +0900 Subject: [PATCH] get out of the loop when subprocess terminated (fixes #56) --- pyknp/utils/process.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyknp/utils/process.py b/pyknp/utils/process.py index 6e56b6a..f2c09ec 100644 --- a/pyknp/utils/process.py +++ b/pyknp/utils/process.py @@ -78,6 +78,8 @@ def alarm_handler(signum, frame): self.process.stdin.write(sentence.encode('utf-8')) self.process.stdin.flush() while True: + if self.process.poll() is not None: + break line = self.process.stdout.readline().decode('utf-8').rstrip() if re.search(pattern, line): break