diff options
author | mjdenkowski <michael.j.denkowski@gmail.com> | 2013-10-18 16:18:04 -0400 |
---|---|---|
committer | mjdenkowski <michael.j.denkowski@gmail.com> | 2013-10-18 16:18:04 -0400 |
commit | af80da3fecbd56554314b1135872272cc7d3793a (patch) | |
tree | 63dd7e160fac5ff31ba3fa6be22e3b7fc0d46851 /realtime | |
parent | 3564060d2567816e526f5c002aee906e85f51d50 (diff) |
wait() to avoid zombies
Diffstat (limited to 'realtime')
-rw-r--r-- | realtime/rt/aligner.py | 3 | ||||
-rw-r--r-- | realtime/rt/decoder.py | 5 | ||||
-rw-r--r-- | 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 = '<seg grammar="{g}">{s}</seg>\n'.format(s=sentence, g=grammar) if grammar else '{}\n'.format(sentence) self.lock.acquire() + input = '<seg grammar="{g}">{s}</seg>\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 ||| <seg grammar="{g}">{s}</seg> ||| {r}\n'.format(s=sentence, g=grammar, r=reference) self.lock.acquire() + input = 'LEARN ||| <seg grammar="{g}">{s}</seg> ||| {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() |