I'm working on a multithreaded Python extension in C that deals a fair bit with the GIL.
There's a problem at exit where code like this shuts down cleanly:
from myextension import ExtensionObject
obj = ExtensionObject()
obj.start()
time.sleep(5)
del obj
# Interpreter exits here
But, if I remove the del obj from the end and let obj go out of scope and get deleted automatically, I get a deadlock while trying to acquire the GIL to do some cleanup in one of the spawned threads.
Is there a fundamental difference between deleting an object and just letting it go out of scope, specifically when it's at the end of program execution?
Edit: Note also that obj = None does the same thing as del obj in this scenario.