attempt better wsjt decoder handling

This commit is contained in:
Jakob Ketterl 2019-12-21 21:08:44 +01:00
parent 9923f5b18e
commit 8fe9bf6292

View File

@ -150,14 +150,15 @@ class WsjtChopper(threading.Thread):
decoder = subprocess.Popen( decoder = subprocess.Popen(
self.decoder_commandline(file), stdout=subprocess.PIPE, cwd=self.tmp_dir, preexec_fn=lambda: os.nice(10) self.decoder_commandline(file), stdout=subprocess.PIPE, cwd=self.tmp_dir, preexec_fn=lambda: os.nice(10)
) )
while True: for line in decoder.stdout.readline():
line = decoder.stdout.readline()
if line is None or (isinstance(line, bytes) and len(line) == 0):
break
self.outputWriter.send(line) self.outputWriter.send(line)
rc = decoder.wait() try:
if rc != 0: rc = decoder.wait(timeout=10)
logger.warning("decoder return code: %i", rc) if rc != 0:
logger.warning("decoder return code: %i", rc)
except subprocess.TimeoutExpired:
logger.warning("subprocess (pid=%i}) did not terminate correctly; sending kill signal.", decoder.pid)
decoder.kill()
os.unlink(file) os.unlink(file)
def run(self) -> None: def run(self) -> None: