kill process properly in test teardown (#4743)

* maybe

* send SIGKILL when killing process
This commit is contained in:
pngwn 2023-06-30 11:49:30 +01:00 committed by GitHub
parent ae80066c8a
commit 57d37d1b9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -92,6 +92,10 @@ function spawn_gradio_app(app, port, verbose) {
}
});
_process.on("exit", () => kill_process(_process));
_process.on("close", () => kill_process(_process));
_process.on("disconnect", () => kill_process(_process));
_process.stderr.on("data", (data) => {
const _data = data.toString();
const is_info = INFO_RE.test(_data);
@ -117,10 +121,7 @@ function spawn_gradio_app(app, port, verbose) {
}
function kill_process(process) {
return new Promise((res, rej) => {
process.on("close", res);
process.kill("SIGTERM");
});
process.kill("SIGKILL");
}
function make_app(demos, port) {
@ -132,8 +133,8 @@ ${demos.map((d) => `from demo.${d}.run import demo as ${d}`).join("\n")}
app = FastAPI()
${demos
.map((d) => `app = gr.mount_gradio_app(app, ${d}, path="/${d}")`)
.join("\n")}
.map((d) => `app = gr.mount_gradio_app(app, ${d}, path="/${d}")`)
.join("\n")}
config = uvicorn.Config(app, port=${port}, log_level="info")
server = uvicorn.Server(config=config)