Skip to content
Snippets Groups Projects
Commit a3cc33d7 authored by Dmitry Kalinkin's avatar Dmitry Kalinkin
Browse files

treewide: use `set -m` and `trap` to cleanup lingering processes

parent 1f0ca504
Branches
No related tags found
No related merge requests found
......@@ -72,6 +72,13 @@ rule backgrounds_ecal_backwards:
threads: workflow.cores
shell:
"""
set -m # monitor mode to prevent lingering shells
cleanup() {{
echo Cleaning up
kill $WORKER_PID $SCHEDULER_PID
}}
trap cleanup EXIT
PORT=$RANDOM
dask scheduler --port $PORT &
export DASK_SCHEDULER=localhost:$PORT
......@@ -87,5 +94,4 @@ PROTON_BEAM_GAS_GEN=$(realpath {input.proton_beam_gas_gen}) \
PROTON_BEAM_GAS_SIM=$(realpath {input.proton_beam_gas_sim}) \
OUTPUT_DIR={output} \
python {input.script}
kill $WORKER_PID $SCHEDULER_PID
"""
......@@ -66,6 +66,7 @@ rule ecal_gaps:
threads: workflow.cores
shell:
"""
set -m # monitor mode to prevent lingering shells
cleanup() {{
echo Cleaning up
kill $WORKER_PID $SCHEDULER_PID
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment