mirror of
https://github.com/YosysHQ/sby.git
synced 2025-04-05 22:14:08 +00:00
Fix a race-condition SbyProc that could truncate output
Present for a long time, but was not easy to hit. Some of my work in progress changes made this much more likely and running the complete test suite in parallel had a good chance of reproducing this for at least one of the tests.
This commit is contained in:
parent
4ab610ce87
commit
5d3f784beb
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue