1

I'm working on Spyder IDE, version 3.0.0. My python version is 2.7.12. For some reason, the atexit mechanism doesn't work on this particular IDE.


Code

import atexit

def done():
    print '2'

atexit.register(done)
print '1'

Result

When I run the script in PyCharm or from Windows cmd, it prints:

1
2

When I run it from Spyder, done function is not being called, and 2 is not printed. The final result is:

1

Does someone knows why is that and how can I fix it?

Thanks!

ibezito
  • 5,782
  • 2
  • 22
  • 46

1 Answers1

0

If you need to use atexit.register(), you can call atexit._run_exitfuncs, as in answer:

https://stackoverflow.com/a/21634308/6669602

(Or you can restart the kernel)

Leo
  • 55
  • 1
  • 6