def _inner(self, result, pool, child_runner): it = pool.imap_unordered(child_runner, self._test_list) while True: try: # A test can't run longer than 2 minutes child_result = it.__next__(120) except StopIteration: return result.add_results(child_result) if child_result.shouldStop: return
def _run_inner(self, result): # We hijack TextTestRunner.run()'s inner logic by passing this # method as if it were a test case. child_runner = _MinimalRunner(self.runner_cls, self.runner_args) pool = multiprocessing.Pool() imap = pool.imap_unordered try: for child_result in imap(child_runner, self._test_list): result.add_results(child_result) if child_result.shouldStop: break return result finally: # Kill the still active workers pool.terminate() pool.join()
def _run_parallel_tests(self, result, pool, child_runner): remaining_ids = set(t.id() for t in self._ptests) it = pool.imap_unordered(child_runner, self._ptests) while True: try: child_result = it.__next__(self.timeout) except StopIteration: return except TimeoutError as e: # Diagnose the names of unfinished tests msg = "%s [unfinished tests: %s]" % (str(e), ", ".join(map(repr, sorted(remaining_ids)))) e.args = (msg,) + e.args[1:] raise e result.add_results(child_result) remaining_ids.discard(child_result.test_id) if child_result.shouldStop: return
def _run_parallel_tests(self, result, pool, child_runner): remaining_ids = set(t.id() for t in self._ptests) it = pool.imap_unordered(child_runner, self._ptests) while True: try: child_result = it.__next__(self.timeout) except StopIteration: return except TimeoutError as e: # Diagnose the names of unfinished tests msg = ("%s [unfinished tests: %s]" % (str(e), ", ".join(map(repr, sorted(remaining_ids))))) e.args = (msg, ) + e.args[1:] raise e result.add_results(child_result) remaining_ids.discard(child_result.test_id) if child_result.shouldStop: return
def _run_parallel_tests(self, result, pool, child_runner): remaining_ids = set(t.id() for t in self._ptests) it = pool.imap_unordered(child_runner, self._ptests) while True: try: child_result = it.__next__(self.timeout) except StopIteration: return except TimeoutError as e: # Diagnose the names of unfinished tests msg = ("Tests didn't finish before timeout (or crashed):\n%s" % "".join("- %r\n" % tid for tid in sorted(remaining_ids))) e.args = (msg, ) + e.args[1:] raise e else: result.add_results(child_result) remaining_ids.discard(child_result.test_id) if child_result.shouldStop: result.shouldStop = True return
def _run_parallel_tests(self, result, pool, child_runner): remaining_ids = set(t.id() for t in self._ptests) it = pool.imap_unordered(child_runner, self._ptests) while True: try: child_result = it.__next__(self.timeout) except StopIteration: return except TimeoutError as e: # Diagnose the names of unfinished tests msg = ("Tests didn't finish before timeout (or crashed):\n%s" % "".join("- %r\n" % tid for tid in sorted(remaining_ids)) ) e.args = (msg,) + e.args[1:] raise e else: result.add_results(child_result) remaining_ids.discard(child_result.test_id) if child_result.shouldStop: result.shouldStop = True return