In the Cython version, the handles are closed in __del__ both for DTraceConsumer and DTraceContinuousConsumer (used by DTraceConsumerThread). However, these are extension types, and Cython does not use __del__ for extension types (for whatever reason), so they will never be called (the explicit del self.consumer in DTraceConsumerThread's destructor, which is called as it's a normal Python object, just ensures the DTraceContinuousConsumer gets deallocated, but the consumer's __del__ still won't be called). I believe using __dealloc__ for the two extension classes would work (though handle must be checked for being non-null first).
This has also exposed a (minor) potential issue: with Cython, __init__ can end up being called multiple times, so technically handle could be initialised twice, leaking the old return from dtrace_open. To be truly correct, either __init__ should guard against this, or __cinit__ should be used instead, which will only ever be called once.
In the Cython version, the handles are closed in
__del__both for DTraceConsumer and DTraceContinuousConsumer (used by DTraceConsumerThread). However, these are extension types, and Cython does not use__del__for extension types (for whatever reason), so they will never be called (the explicitdel self.consumerin DTraceConsumerThread's destructor, which is called as it's a normal Python object, just ensures the DTraceContinuousConsumer gets deallocated, but the consumer's__del__still won't be called). I believe using__dealloc__for the two extension classes would work (thoughhandlemust be checked for being non-null first).This has also exposed a (minor) potential issue: with Cython,
__init__can end up being called multiple times, so technicallyhandlecould be initialised twice, leaking the old return fromdtrace_open. To be truly correct, either__init__should guard against this, or__cinit__should be used instead, which will only ever be called once.