2010/10/29 Thomas Sturm <[email protected]>:
> The class in question is Python-wrapped C-Code, which spawns a process. That 
> process is a Lisp System, which occupies a considerable amount of memory. I 
> would thus be very happy about any advice how to arrange my code in such a 
> way that the destructor - or more generally the corresponding code for the 
> deletion of the questionable process - is called on termination of the Python 
> program under any circumstances - including abnormal termination due to bugs, 
> kill -9 from outside, or whatever. Is this possible?

In case of "kill -9" it is impossible, this signal cannot be caught by
a running process.  Other cases (e.g. unexpected exceptions or the
like) can be handled, but do *not* use __del__ for this purpose!
Implement a deterministic resource management, e.g. using a context
manager, or by providing an explicit ".close()" or ".cleanup()" (or
whatever you want to call it) method, and call this method at the
appropriate places.

Sebastian Wiesner
_______________________________________________
PySide mailing list
[email protected]
http://lists.openbossa.org/listinfo/pyside

Reply via email to