Fix high CPU usage after compilation

This commit is contained in:
Thiago Alves 2018-08-17 10:34:52 -05:00 committed by GitHub
parent 987954d21a
commit 48c68eed7b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 6 deletions

View File

@ -41,19 +41,21 @@ class NonBlockingStreamReader:
def _populateQueue(stream, queue):
'''
Collect lines from 'stream' and put them in 'quque'.
Collect lines from 'stream' and put them in 'queue'.
'''
while True:
#while True:
while (self.end_of_stream == False):
line = stream.readline()
if line:
queue.put(line)
if (line.find("Compilation finished with errors!") >= 0 or line.find("Compilation finished successfully!") >= 0):
self.end_of_stream = True
else:
self.end_of_stream = True
#raise UnexpectedEndOfStream
raise UnexpectedEndOfStream
self._t = Thread(target = _populateQueue,
args = (self._s, self._q))
self._t = Thread(target = _populateQueue, args = (self._s, self._q))
self._t.daemon = True
self._t.start() #start collecting lines from the stream