Category: signal

Problem

Handle SIGINT/SIGTERM gracefully.

Solution

  signal.signal(signal.SIGINT, lambda s, f: sys.exit(0))
  

Notes

  • Adapt variable names and paths to your project
  • Add error handling for production use
  • See related chapters in the Learning Path