def startXvfb(self, command, machine): for _ in range(5): self.diag.info("Starting Xvfb using args " + repr(command)) # Ignore job control signals for remote processes # Otherwise the ssh process gets killed, but the stuff it's started remotely doesn't, and we leak Xvfb processes preexec_fn = None if machine == "localhost" else self.ignoreSignals xvfbOrSshProc = subprocess.Popen(command, preexec_fn=preexec_fn, stdin=open(os.devnull), stdout=subprocess.PIPE, stderr=open(os.devnull, "w"), universal_newlines=True) line = plugins.retryOnInterrupt(xvfbOrSshProc.stdout.readline) if "Time Out!" in line: xvfbOrSshProc.wait() xvfbOrSshProc.stdout.close() self.diag.info("Timed out waiting for Xvfb to come up") # We try again and hope for a better process ID! continue try: displayNum, xvfbPid = list(map(int, line.strip().split(","))) xvfbOrSshProc.stdout.close() return self.getDisplayName(machine, displayNum), xvfbPid, xvfbOrSshProc except ValueError: # pragma : no cover - should never happen, just a fail-safe sys.stderr.write( "ERROR: Failed to parse startXvfb.py line :\n " + line + "\n") xvfbOrSshProc.stdout.close() return None, None, None messages = "Failed to start Xvfb in 5 attempts, giving up" plugins.printWarning(messages) return None, None, None
def startWindowManager(self, command, machine): self.diag.info("Starting window manager") preexec_fn = None if machine == "localhost" else self.ignoreSignals wmProc = subprocess.Popen(command, preexec_fn=preexec_fn, stdin=open(os.devnull), stdout=subprocess.PIPE, stderr=open(os.devnull, "w")) line = plugins.retryOnInterrupt(wmProc.stdout.readline) try: wmPid = int(line.strip()) wmProc.stdout.close() except ValueError: sys.stderr.write("ERROR: Failed to start window manager") wmProc.stdout.close() return None, None return wmPid, wmProc
def findPerformanceMachines(self, test, fileStem): perfMachines = [] resources = test.getCompositeConfigValue("performance_test_resource", fileStem) for resource in resources: perfMachines += plugins.retryOnInterrupt( self.queueMachineInfo.findResourceMachines, resource) rawPerfMachines = MachineInfoFinder.findPerformanceMachines( self, test, fileStem) for machine in rawPerfMachines: if machine != "any": perfMachines += self.queueMachineInfo.findActualMachines( machine) if "any" in rawPerfMachines and len(resources) == 0: return rawPerfMachines else: return perfMachines
def findRunningJobs(self, machine): return plugins.retryOnInterrupt(self._findRunningJobs, machine)
def wait(self, process): try: plugins.retryOnInterrupt(process.wait) except OSError: # pragma: no cover - workaround for Python bugs only pass # safest, as there are python bugs in this area