Hello, I have a Python module written in C that spawns and kills processes using OS-specific mechanisms. I want to kill all spawned processes when the interpreter exits. I tried to wrap every spawned process in a Python object like this:
import cmodule class Process: __init__(self, execname): self.pid = cmodule.spawn(execname) __del__(self): cmodule.kill(self.pid) p = Process("foo") but this does not work, I am getting and exception inidicating that 'cmodule' is 'None' in '__del__()'. Moreover, the Language Reference states that "It is not guaranteed that __del__() methods are called for objects that still exist when the interpreter exits", so it looks like this approach is wrong anyway. How do I do this right? Thanks very much in advance Grzegorz PS: Python 2.3.3 -- http://mail.python.org/mailman/listinfo/python-list