you’re entering a minefield there…
Since you’ve built your flowgraph using GRC, you have a
python-constructed flowgraph. That’s why things start to get confusing
for the c++ developer.
First of all, destructors of python objects are called whenever the
python runtime feels like it - this often happens when you do something
object_name = None
but it doesn’t necessarily has to happen right away. The Garbage
Collector can choose when to do it, and sometimes, it decides not to do
it at all - if your program terminates first, this might be the case.
Furthermore, if it decides that at the end of runtime, it should
destruct its output stream file handles before destructing your block,
your printf output might be lost.
Then: You have a C++ object wrapped by SWIG. So, what you’re seeing in
Python is not actually an instance of your block, it is a SWIG object
holding a reference to such an instance. Usually, when that Swig
Object’s python destructor is called, it should delete the block
instance, too, but then again, if I knew what really happens inside
SWIG, I’d feel a lot wiser.
Lastly: Destructors doing actual work is a tricky thing. Mostly,
because, what does the runtime (both, c++ or python) do when a
destructor throws an exception? In that case, should the runtime ignore
it and just think “meh, whatever, it’s dead anyway” or should it cause
the program to exit with a failure state? And: what if a C++ destructor
fails that got called by the python garbage collector? That shouldn’t
crash the global python interpreter, should it?
So these are the pitfalls I could think of. Maybe the situation is a lot
easier, though Post some code, maybe a github gist or a pastebin!