def startXvfb(self, startArgs, machine): for _ in range(5): self.diag.info("Starting Xvfb using args " + repr(startArgs)) # 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 displayProc = subprocess.Popen(startArgs, preexec_fn=preexec_fn, stdin=open(os.devnull), stdout=subprocess.PIPE, stderr=open(os.devnull, "w")) line = plugins.retryOnInterrupt(displayProc.stdout.readline) if "Time Out!" in line: displayProc.wait() displayProc.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, pid = map(int, line.strip().split(",")) displayProc.stdout.close() return self.getDisplayName(machine, displayNum), pid, displayProc 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") displayProc.stdout.close() return None, None, None messages = "Failed to start Xvfb in 5 attempts, giving up" plugins.printWarning(messages) return None, None, None
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 startXvfb(self, startArgs, machine): for i in range(5): self.diag.info("Starting Xvfb using args " + repr(startArgs)) self.displayProc = subprocess.Popen(startArgs, stdin=open(os.devnull), stdout=subprocess.PIPE, stderr=subprocess.STDOUT) line = plugins.retryOnInterrupt(self.displayProc.stdout.readline) if "Time Out!" in line: self.displayProc.wait() self.displayProc.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, pid = map(int, line.strip().split(",")) self.displayProc.stdout.close() return self.getDisplayName(machine, displayNum), pid except ValueError: #pragma : no cover - should never happen, just a fail-safe plugins.log.info("Failed to parse line :\n " + line + self.displayProc.stdout.read()) return None, None messages = "Failed to start Xvfb in 5 attempts, giving up" plugins.printWarning(messages) return None, None
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
def findRunningJobs(self, machine): return plugins.retryOnInterrupt(self._findRunningJobs, machine)