mirror of
https://github.com/gradio-app/gradio.git
synced 2025-04-12 12:40:29 +08:00
kill process properly in test teardown (#4743)
* maybe * send SIGKILL when killing process
This commit is contained in:
parent
ae80066c8a
commit
57d37d1b9f
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user