Skip to content

Commit f8f9f13

Browse files
gaogaotiantianHyukjinKwon
authored andcommitted
[SPARK-54572][PYTHON][FOLLOWUP] Cleanup all child processes for vscode script
### What changes were proposed in this pull request? Cleanup all the child processes when `run-with-vscode-breakpoint` exits with `kill -- -$$` (kill the process group of this script). ### Why are the changes needed? `debugpy` will leave some long live processes (probably due to how we used it, multiple connections to vscode). Users might not aware of this or they don't know how to clear them. This is a helpful way to just kill everything started by the script. Considering the script is for dev-debug only, it should be safe. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Locally confirmed that all the debug processes are killed after script exits. ### Was this patch authored or co-authored using generative AI tooling? No Closes #53551 from gaogaotiantian/cleanup-process. Authored-by: Tian Gao <gaogaotiantian@hotmail.com> Signed-off-by: Hyukjin Kwon <gurwls223@apache.org>
1 parent 588fab4 commit f8f9f13

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

python/run-with-vscode-breakpoints

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,11 @@ set -- "${new_args[@]}"
6969
export DEBUGPY_ADAPTER_ENDPOINTS=$VSCODE_DEBUGPY_ADAPTER_ENDPOINTS
7070
export PYTHONPATH="$FWDIR/conf_vscode:$PYTHONPATH"
7171

72+
# debugpy will leave some debug processes in the system
73+
# so we need to cleanup all the child processes after exiting
74+
function cleanup {
75+
kill -- -$$
76+
}
77+
trap cleanup EXIT INT TERM
78+
7279
exec "$@"

0 commit comments

Comments
 (0)