Bug 967799. b2gautomation: Wait on the queue instead of polling it. r=ahal

This replaces the stdout property with a getStdoutLines functions that waits on
the queue instead of polling it in a tight loop. This should reduce the amount
of time spent in runreftestb2g.py dramatically.

--HG--
extra : rebase_source : 6e14568285c9269d06848e441f3fa3420e76d6a4
This commit is contained in:
Jeff Muizelaar 2014-02-11 13:43:33 -05:00
parent 4b53efef70
commit 27c7be0974

View File

@ -140,11 +140,9 @@ class B2GRemoteAutomation(Automation):
output.
"""
timeout = timeout or 120
responseDueBy = time.time() + timeout
while True:
currentlog = proc.stdout
currentlog = proc.getStdoutLines(timeout)
if currentlog:
responseDueBy = time.time() + timeout
print currentlog
# Match the test filepath from the last TEST-START line found in the new
# log content. These lines are in the form:
@ -155,11 +153,10 @@ class B2GRemoteAutomation(Automation):
if hasattr(self, 'logFinish') and self.logFinish in currentlog:
return 0
else:
if time.time() > responseDueBy:
self.log.info("TEST-UNEXPECTED-FAIL | %s | application timed "
"out after %d seconds with no output",
self.lastTestSeen, int(timeout))
return 1
self.log.info("TEST-UNEXPECTED-FAIL | %s | application timed "
"out after %d seconds with no output",
self.lastTestSeen, int(timeout))
return 1
def getDeviceStatus(self, serial=None):
# Get the current status of the device. If we know the device
@ -329,16 +326,22 @@ class B2GRemoteAutomation(Automation):
# a dummy value to make the automation happy
return 0
@property
def stdout(self):
def getStdoutLines(self, timeout):
# Return any lines in the queue used by the
# b2g process handler.
lines = []
# get all of the lines that are currently available
while True:
try:
lines.append(self.queue.get_nowait())
except Queue.Empty:
break
# wait 'timeout' for any additional lines
try:
lines.append(self.queue.get(True, timeout))
except Queue.Empty:
pass
return '\n'.join(lines)
def wait(self, timeout=None):