How does the Python interpreter exit after finishing executing code?

Viewed 327

Generally, How does the Python interpreter exits?

For example:

print('aaa')

After executing this code, aside from calling exit handlers registered with atexit what else does the interpreter do to free its resources upon normal exit (with no exceptions raised) and without calling os._exit?

Is there a main hook/function that the Python interpreter calls on every exit?

print('aaa')
_exit()  # called automatically on every exit
1 Answers
Related