3
0
Fork 0
mirror of https://github.com/YosysHQ/sby.git synced 2025-04-11 00:13:33 +00:00

Merge pull request from jix/sbyproc-truncated-output

Fix a race-condition SbyProc that could truncate output
This commit is contained in:
Jannis Harder 2022-07-13 17:30:36 +02:00 committed by GitHub
commit 07d19b202b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -183,17 +183,12 @@ class SbyProc:
self.running = True
return
while True:
outs = self.p.stdout.readline().decode("utf-8")
if len(outs) == 0: break
if outs[-1] != '\n':
self.linebuffer += outs
break
outs = (self.linebuffer + outs).strip()
self.linebuffer = ""
self.handle_output(outs)
self.read_output()
if self.p.poll() is not None:
# The process might have written something since the last time we checked
self.read_output()
if not self.silent:
self.task.log(f"{self.info}: finished (returncode={self.p.returncode})")
self.task.update_proc_stopped(self)
@ -231,6 +226,17 @@ class SbyProc:
next_proc.poll()
return
def read_output(self):
while True:
outs = self.p.stdout.readline().decode("utf-8")
if len(outs) == 0: break
if outs[-1] != '\n':
self.linebuffer += outs
break
outs = (self.linebuffer + outs).strip()
self.linebuffer = ""
self.handle_output(outs)
class SbyAbort(BaseException):
pass