Unexpected exit of Python script

Donn donn.ingle at gmail.com
Wed Oct 14 14:56:01 CEST 2009

On Wednesday 14 October 2009 14:23:11 vicky wrote:
> I just want to know that, due to any reason if a script exits, is
> their some way to release all the resources acquired by the script
> during execution ?
Python cleans-up after itself so I would not worry about that until you are an 
expert and need to split hairs. Just get on with learning and writing code.

Look at exceptions (try, except) for this kind of thing -- but it's a basic 
part of learning Python anyway.

About the only thing I ever found I could not catch was a segfault (under 
Linux) and to get around that I open my main app from a smaller one using the 
subprocess module. When the main app crashes (which it does sometime) that 
process dies suddenly, but it falls-back to the original script which then 
detects the error return code and can continue whatever it needs to do.


More information about the Python-list mailing list