4

I have a python script which makes use of multiprocessing. I like to debug my scripts in Eclipse, but with multiprocessing, I always have to manually kill the spawned children processes after termination. How can I catch the Eclipse termination action in the script so it can clean up?

juliomalegria
  • 24,229
  • 14
  • 73
  • 89
zer0stimulus
  • 22,306
  • 30
  • 110
  • 141

1 Answers1

3

By catching the eclipse termination, do you mean catching the event of someone pressing the "Terminate" button while debugging? If so, I don't think there is an exception or event you can catch.

Here is a few things i tried on the side that does not work either: 1. Adding signal handlers for SIGTERM, SIGNTEAL, and SIGINT, but no luck. 2. try the atexit module, it only works only normal program termination.

xkrz
  • 166
  • 9
  • 2
    The reason this doesn't work is that eclipse insists on sending SIGKILL instead of SIGTERM, which will terminate your application without giving you a chance to handle it, see also http://stackoverflow.com/questions/677531/is-it-possible-for-eclipse-to-terminate-gently-instead-of-using-sigkill – Joakim Lundborg Jul 11 '12 at 14:23