When I run a python program from VS2017-Pro using the debugger, the destructor is not called automatically when the program exits. If the python program is executed directly from a command prompt, the destructor is called.
Here’s a code snippet:
import MyStuff
thing = MyStuff.thing()
# eof
MyStuff.pyd is a C++ library that contains the constructor, MyStuff::thing() and destructor, MyStuff::~thing().
I can see ~thing() being called when I run this program from the command prompt. However, when I run it from VisualStudio, the destructor is not called. If I explicitly call
del thing
, the destructor is called in both cases.
Any ideas why this is and if it can be fixed?
One possibility is that VS is holding a reference to thing
which prevents the garbage collector from destroying it.
Thanks for your help.