def start(data_dir='/tmp', port=5000, debug=False, host_exec=None): signal.signal(signal.SIGUSR2, stack_trace_handler) BlockadeManager.set_data_dir(data_dir) if host_exec: BlockadeManager.set_host_exec(host_exec) app.debug = debug http_server = WSGIServer(('', port), app) http_server.serve_forever()
def _wrapped_run(*args, **kwargs): host_exec = HostExec() BlockadeManager.set_host_exec(host_exec) def _cleanup_host_exec(*args): host_exec.close() os._exit(0) signal.signal(signal.SIGTERM, _cleanup_host_exec) signal.signal(signal.SIGUSR2, stack_trace_handler) real_run(*args, **kwargs)