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!
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)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.