Below is the code written in a script say test_atexit.py
def exit_function():
print "I am in exit function"
import atexit
atexit.register(exit_function)
print "I am in main function"
When i run the function using python2.4 then exit_function is being called
$python2.4 test_atexit.py
I am in main function
I am in exit function
When i run the same using ipython then exit_function is not being called
$ ipython
In [1]: %run test_atexit.py
I am in main function
In [2]:
why exit_function is not called when running script using Ipython and how can i make ipython to call exit_function