Borner le nettoyage PDAL à notre run et supprimer le pkill à chaque sortie
This commit is contained in:
@ -15,6 +15,10 @@ from .gpu import log_gpu_status
|
|||||||
|
|
||||||
logger = logging.getLogger("lidar")
|
logger = logging.getLogger("lidar")
|
||||||
|
|
||||||
|
# Motif pkill des processus PDAL de CE run (renseigné dans main) — cf.
|
||||||
|
# _kill_orphan_pdal : borné à notre output pour épargner les autres runs.
|
||||||
|
_pdal_kill_pattern = None
|
||||||
|
|
||||||
|
|
||||||
def setup_logging(verbose=False, debug=False):
|
def setup_logging(verbose=False, debug=False):
|
||||||
"""Configure the 'lidar' logger.
|
"""Configure the 'lidar' logger.
|
||||||
@ -273,11 +277,15 @@ def main():
|
|||||||
from .gpu import restrict_gpus
|
from .gpu import restrict_gpus
|
||||||
restrict_gpus(gpu_ids)
|
restrict_gpus(gpu_ids)
|
||||||
|
|
||||||
# Kill orphan PDAL processes on interrupt or termination
|
# Kill orphan PDAL processes on interrupt or termination. Le motif est
|
||||||
|
# borné à NOTRE répertoire temporaire (pdal pipeline <output>/temp/…) : un
|
||||||
|
# pkill global massacrerient les PDAL des autres runs de la machine (ex.
|
||||||
|
# job webapp concurrent). Pas de hook atexit : une sortie normale n'a
|
||||||
|
# aucune raison de tuer quoi que ce soit.
|
||||||
|
global _pdal_kill_pattern
|
||||||
|
_pdal_kill_pattern = f"pdal pipeline {args.output}/temp/"
|
||||||
signal.signal(signal.SIGINT, _kill_orphan_pdal)
|
signal.signal(signal.SIGINT, _kill_orphan_pdal)
|
||||||
signal.signal(signal.SIGTERM, _kill_orphan_pdal)
|
signal.signal(signal.SIGTERM, _kill_orphan_pdal)
|
||||||
import atexit
|
|
||||||
atexit.register(_kill_orphan_pdal)
|
|
||||||
|
|
||||||
log_gpu_status()
|
log_gpu_status()
|
||||||
|
|
||||||
@ -394,12 +402,17 @@ def main():
|
|||||||
|
|
||||||
|
|
||||||
def _kill_orphan_pdal(signum=None, frame=None):
|
def _kill_orphan_pdal(signum=None, frame=None):
|
||||||
"""Kill orphan PDAL processes on interrupt or exit."""
|
"""Kill orphan PDAL processes of THIS run on interrupt or termination."""
|
||||||
import subprocess
|
import subprocess
|
||||||
# Belt-and-suspenders: os.killpg below is the primary mechanism.
|
# Belt-and-suspenders: os.killpg below is the primary mechanism.
|
||||||
# This handles the edge case where a child escapes the process group.
|
# This handles the edge case where a child escapes the process group.
|
||||||
|
# Motif borné à notre output (cf. main) pour ne pas tuer les PDAL des
|
||||||
|
# autres runs de la machine.
|
||||||
|
if _pdal_kill_pattern:
|
||||||
try:
|
try:
|
||||||
subprocess.run(["pkill", "-9", "-f", "pdal pipeline"], capture_output=True, timeout=3)
|
import re
|
||||||
|
subprocess.run(["pkill", "-9", "-f", re.escape(_pdal_kill_pattern)],
|
||||||
|
capture_output=True, timeout=3)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
if signum is not None:
|
if signum is not None:
|
||||||
|
|||||||
Reference in New Issue
Block a user