Nettoyage des processus PDAL orphelins à l'interruption
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 <noreply@anthropic.com>
This commit is contained in:
@ -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)
|
||||
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(
|
||||
Reference in New Issue
Block a user