bpo-36670, regrtest: Fix WindowsLoadTracker() for partial line (GH-16550)

WindowsLoadTracker.read_output() now uses a short buffer for
incomplete line.
This commit is contained in:
Victor Stinner 2019-10-03 01:04:09 +02:00 committed by GitHub
parent 61691d8336
commit 3e04cd268e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -32,6 +32,7 @@ class WindowsLoadTracker():
def __init__(self): def __init__(self):
self.load = 0.0 self.load = 0.0
self.counter_name = '' self.counter_name = ''
self._buffer = b''
self.popen = None self.popen = None
self.start() self.start()
@ -100,7 +101,9 @@ def read_output(self):
if res != 0: if res != 0:
return return
output = overlapped.getbuffer() # self._buffer stores an incomplete line
output = self._buffer + overlapped.getbuffer()
output, _, self._buffer = output.rpartition(b'\n')
return output.decode('oem', 'replace') return output.decode('oem', 'replace')
def getloadavg(self): def getloadavg(self):