Using atexit.register(function)
to register a function to be called when your python script exits is a common practice.
The problem is that I identified a case when this fails in an ugly way: if your script it executed from another python script using the execfile()
.
In this case you will discover that Python will not be able to locate your function when it does exits, and this makes sense.
My question is how to keep this functionality in a way that does not presents this issue.