bpo-36670, regrtest: Fix WindowsLoadTracker() for partial line (GH-16… · python/cpython@3e04cd2 (original) (raw)

Original file line number Diff line number Diff line change
@@ -32,6 +32,7 @@ class WindowsLoadTracker():
32 32 def __init__(self):
33 33 self.load = 0.0
34 34 self.counter_name = ''
35 +self._buffer = b''
35 36 self.popen = None
36 37 self.start()
37 38
@@ -100,7 +101,9 @@ def read_output(self):
100 101 if res != 0:
101 102 return
102 103
103 -output = overlapped.getbuffer()
104 +# self._buffer stores an incomplete line
105 +output = self._buffer + overlapped.getbuffer()
106 +output, _, self._buffer = output.rpartition(b'\n')
104 107 return output.decode('oem', 'replace')
105 108
106 109 def getloadavg(self):