Skip to content

Commit 3e04cd2

Browse files
authored
bpo-36670, regrtest: Fix WindowsLoadTracker() for partial line (GH-16550)
WindowsLoadTracker.read_output() now uses a short buffer for incomplete line.
1 parent 61691d8 commit 3e04cd2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Diff for: Lib/test/libregrtest/win_utils.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class WindowsLoadTracker():
3232
def __init__(self):
3333
self.load = 0.0
3434
self.counter_name = ''
35+
self._buffer = b''
3536
self.popen = None
3637
self.start()
3738

@@ -100,7 +101,9 @@ def read_output(self):
100101
if res != 0:
101102
return
102103

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')
104107
return output.decode('oem', 'replace')
105108

106109
def getloadavg(self):

0 commit comments

Comments
 (0)