mycroft-precise icon indicating copy to clipboard operation
mycroft-precise copied to clipboard

precise_runner is blocking on line proc.stdout.readline()

Open cezary69 opened this issue 5 years ago • 2 comments

Hello, I can't get working binary engine with precise_runner on Ubuntu 18.04 with python 3.6.9 The engine itself works fine and gives a correct output with command line ./precise-engine/precise-engine ./hey-mycroft.pb 4096 <hey-mycroft.wav
but when run with precise_runner it's blocking in method get_prediction of PreciseEngine class in the last line

return float(self.proc.stdout.readline())

looks like the output of engine is buffered and not flushed running python3 unbuffered (with -u) doesn't helps (program ends immediately)

I think the solution would be flushing output of precise-engine after writing each line

cezary69 avatar Jul 02 '20 08:07 cezary69

Hmm, not sure because precise-engine already flushes stdout here.

MatthewScholefield avatar Jul 02 '20 08:07 MatthewScholefield

I simulated the engine with this simple code

import sys import random

while True: chunk = sys.stdin.buffer.read(2048) sys.stdout.write("{}\n".format(random.random())) #sys.stdout.flush()

when run with sys.stdout.flush() commented out the runner blocks as described before but with sys.stdout.flush() uncommented it works fine

maybe using stdout.buffer.write in precise-engine is the issue ?

cezary69 avatar Jul 02 '20 09:07 cezary69