I am trying to add a atexit handler to my code. But I find that if I have imported threading module, it gives me an KeyError exception. Is this a bug in python threading module?
#!/usr/bin/python2.7
import threading
# Register a signal handler to exit gracefully
def exit_gracefully():
print 'Exiting ...'
import sys
sys.exit(1)
import atexit
atexit.register(exit_gracefully)
On running the above script, I get
Exiting ...
Exception KeyError: KeyError(139697538152192,) in <module 'threading' from '/usr/lib/python2.7/threading.pyc'> ignored