some more sleep removale

This commit is contained in:
Anthony Scopatz 2016-11-06 23:01:08 -05:00
parent 4bf8a1e566
commit 8603909be1

View file

@ -98,10 +98,11 @@ class QueueReader:
not self.thread.is_alive()) \ not self.thread.is_alive()) \
and self.queue.empty() and self.queue.empty()
def read_queue(self, timeout=None): def read_queue(self):
"""Reads a single chunk from the queue. This is non-blocking.""" """Reads a single chunk from the queue. This is blocking if
the timeout is None and non-blocking otherwise.
"""
try: try:
#return self.queue.get(block=False)
return self.queue.get(block=True, timeout=self.timeout) return self.queue.get(block=True, timeout=self.timeout)
except queue.Empty: except queue.Empty:
return b'' return b''
@ -601,9 +602,7 @@ class PopenThread(threading.Thread):
cnt = min(cnt + 1, 1000) cnt = min(cnt + 1, 1000)
else: else:
cnt = 1 cnt = 1
time.sleep(self.timeout * cnt) procout.timeout = procerr.timeout = self.timeout * cnt
#else:
# time.sleep(self.timeout)
if self.suspended: if self.suspended:
return return
# close files to send EOF to non-blocking reader. # close files to send EOF to non-blocking reader.
@ -611,8 +610,8 @@ class PopenThread(threading.Thread):
self.orig_stderr.close() self.orig_stderr.close()
# read in the remaining data in a blocking fashion. # read in the remaining data in a blocking fashion.
while not procout.is_fully_read() or not procerr.is_fully_read(): while not procout.is_fully_read() or not procerr.is_fully_read():
i = self._read_write(procout, stdout, sys.__stdout__) self._read_write(procout, stdout, sys.__stdout__)
j = self._read_write(procerr, stderr, sys.__stderr__) self._read_write(procerr, stderr, sys.__stderr__)
# kill the process if it is still alive. Happens when piping. # kill the process if it is still alive. Happens when piping.
if proc.poll() is None: if proc.poll() is None:
proc.terminate() proc.terminate()