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/rt/decoder.py | |
parent | 3564060d2567816e526f5c002aee906e85f51d50 (diff) |
wait() to avoid zombies
Diffstat (limited to 'realtime/rt/decoder.py')
-rw-r--r-- | realtime/rt/decoder.py | 5 |
1 files changed, 3 insertions, 2 deletions
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() |