def async_wrapper(job, ts_args, func_args): """Setup test-suite in this subprocess and run something. Because of multipocessing, capture excptions and log messages, and return them. """ global clean_db try: start_time = time.time() if not clean_db: lnt.server.db.v4db.V4DB.close_all_engines() clean_db = True note("Running async wrapper: {} ".format(job.__name__)+ str(os.getpid())) _v4db = current_app.old_config.get_database(ts_args['db']) #with contextlib.closing(_v4db) as db: ts = _v4db.testsuite[ts_args['tsname']] nothing = job(ts, **func_args) assert nothing is None end_time = time.time() delta = end_time-start_time msg = "Finished: {name} in {time:.2f}s ".format(name=job.__name__, time=delta) if delta < 100: note(msg) else: warning(msg) except: # Put all exception text into an exception and raise that for our # parent process. error("Subprocess failed with:" + "".join(traceback.format_exception(*sys.exc_info()))) sys.exit(1) sys.exit(0)
def async_wrapper(job, ts_args, func_args): """Setup test-suite in this subprocess and run something. Because of multipocessing, capture excptions and log messages, and return them. """ global clean_db try: start_time = time.time() if not clean_db: lnt.server.db.v4db.V4DB.close_all_engines() clean_db = True note("Running async wrapper: {} ".format(job.__name__)+ str(os.getpid())) _v4db = current_app.old_config.get_database(ts_args['db']) # with contextlib.closing(_v4db) as db: ts = _v4db.testsuite[ts_args['tsname']] nothing = job(ts, **func_args) assert nothing is None end_time = time.time() delta = end_time-start_time msg = "Finished: {name} in {time:.2f}s ".format(name=job.__name__, time=delta) if delta < 100: note(msg) else: warning(msg) except Exception: # Put all exception text into an exception and raise that for our # parent process. error("Subprocess failed with:" + "".join(traceback.format_exception(*sys.exc_info()))) sys.exit(1) sys.exit(0)
def log_exception(self, exc_info): # We need to stringify the traceback, since logs are sent via # pickle. error("Exception: " + traceback.format_exc())