From 0904592fa2bcfc563086259fe207c4a6f7708b95 Mon Sep 17 00:00:00 2001 From: Jacquin Antoine Date: Sun, 10 May 2026 11:58:30 +0200 Subject: [PATCH] =?UTF-8?q?Nettoyage=20des=20processus=20PDAL=20orphelins?= =?UTF-8?q?=20=C3=A0=20l'interruption?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ajout de signal handlers (SIGINT/SIGTERM) et atexit pour tuer les processus pdal orphelins quand le pipeline est interrompu ou se termine. Utilise pkill -f pdal pour nettoyer. Co-Authored-By: Claude Opus 4.6 --- lidar_pipeline/cli.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/lidar_pipeline/cli.py b/lidar_pipeline/cli.py index 672ec85..87fb1bb 100644 --- a/lidar_pipeline/cli.py +++ b/lidar_pipeline/cli.py @@ -5,6 +5,8 @@ Handles argument parsing, logging configuration, and entry point. import argparse import logging +import os +import signal import sys from .pipeline import LidarArchaeoPipeline @@ -145,6 +147,12 @@ Exemples: logger.info("Pipeline LiDAR Archéologique") logger.info("=" * 60) + # Kill orphan PDAL processes on interrupt or termination + signal.signal(signal.SIGINT, _kill_orphan_pdal) + signal.signal(signal.SIGTERM, _kill_orphan_pdal) + import atexit + atexit.register(_kill_orphan_pdal) + log_gpu_status() try: @@ -191,4 +199,21 @@ Exemples: pipeline.process_all() except Exception as e: logger.error(f"Erreur fatale: {e}", exc_info=True) - sys.exit(1) \ No newline at end of file + sys.exit(1) + + +def _kill_orphan_pdal(signum=None, frame=None): + """Kill orphan PDAL processes on interrupt or exit.""" + import subprocess + try: + subprocess.run(["pkill", "-f", "pdal"], capture_output=True, timeout=5) + except Exception: + pass + if signum is not None: + logger.info("Interruption — nettoyage des processus PDAL") + sys.exit(130) + + +def main(): + """Entry point for the LiDAR archaeological pipeline.""" + parser = argparse.ArgumentParser( \ No newline at end of file