Index: lnt/util/async_ops.py =================================================================== --- lnt/util/async_ops.py +++ lnt/util/async_ops.py @@ -29,22 +29,21 @@ JOBS = [] - def launch_workers(): """Make sure we have a worker pool ready to queue.""" global WORKERS if not WORKERS: note("Starting workers") - manager = Manager() + manager = Manager() try: - current_app.config['mem_logger'].buffer = manager.list(current_app.config['mem_logger'].buffer) + current_app.config['mem_logger'].buffer = \ + manager.list(current_app.config['mem_logger'].buffer) except RuntimeError: # It might be the case that we are not running in the app. # In this case, don't bother memory logging, stdout should # sufficent for console mode. pass - atexit.register(cleanup) - signal.signal(signal.SIGTERM, sigHandler) + def sigHandler(signo, frame): sys.exit(0) @@ -57,6 +56,11 @@ if p.is_alive: p.join() + +atexit.register(cleanup) +signal.signal(signal.SIGTERM, sigHandler) + + def async_fieldchange_calc(db_name, ts, run): """Run regenerate field changes in the background.""" func_args = {'run_id': run.id}