From fcaaa588bc1cac13c41d5115e54a9cd07da73cdc Mon Sep 17 00:00:00 2001 From: mjdenkowski Date: Fri, 18 Oct 2013 16:18:04 -0400 Subject: wait() to avoid zombies --- realtime/rt/aligner.py | 3 +++ realtime/rt/decoder.py | 5 +++-- realtime/rt/rt.py | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/realtime/rt/aligner.py b/realtime/rt/aligner.py index bcc1ef87..c34805eb 100644 --- a/realtime/rt/aligner.py +++ b/realtime/rt/aligner.py @@ -57,8 +57,11 @@ class ForceAligner: if not force: self.lock.acquire() self.fwd_align.stdin.close() + self.fwd_align.wait() self.rev_align.stdin.close() + self.rev_align.wait() self.tools.stdin.close() + self.tools.wait() if not force: self.lock.release() diff --git a/realtime/rt/decoder.py b/realtime/rt/decoder.py index e6e7489d..ed45c248 100644 --- a/realtime/rt/decoder.py +++ b/realtime/rt/decoder.py @@ -13,13 +13,14 @@ class Decoder: if not force: self.lock.acquire() self.decoder.stdin.close() + self.decoder.wait() if not force: self.lock.release() def decode(self, sentence, grammar=None): '''Threadsafe, FIFO''' - input = '{s}\n'.format(s=sentence, g=grammar) if grammar else '{}\n'.format(sentence) self.lock.acquire() + input = '{s}\n'.format(s=sentence, g=grammar) if grammar else '{}\n'.format(sentence) self.decoder.stdin.write(input) hyp = self.decoder.stdout.readline().strip() self.lock.release() @@ -71,8 +72,8 @@ class MIRADecoder(Decoder): def update(self, sentence, grammar, reference): '''Threadsafe, FIFO''' - input = 'LEARN ||| {s} ||| {r}\n'.format(s=sentence, g=grammar, r=reference) self.lock.acquire() + input = 'LEARN ||| {s} ||| {r}\n'.format(s=sentence, g=grammar, r=reference) self.decoder.stdin.write(input) log = self.decoder.stdout.readline().strip() self.lock.release() diff --git a/realtime/rt/rt.py b/realtime/rt/rt.py index 7cc5bc10..d1d01ad8 100644 --- a/realtime/rt/rt.py +++ b/realtime/rt/rt.py @@ -140,7 +140,9 @@ class RealtimeTranslator: self.tokenizer_lock.acquire() self.detokenizer_lock.acquire() self.tokenizer.stdin.close() + self.tokenizer.wait() self.detokenizer.stdin.close() + self.detokenizer.wait() if not force: self.tokenizer_lock.release() self.detokenizer_lock.release() -- cgit v1.2.3