Open Beefster09 opened 6 years ago
Please clarify or provide a supporting link.
Most things of this nature do their resource management through __enter__
and __exit__
(so that it works with with
) rather than relying on refcounting and the immediate object destruction and __del__
call. Since only cPython has the immediate destruction behavior, this would cause severe resource leaks on other implementations of Python that do not use refcounting for object lifetime.
Even on cPython, you can create a resource leak by keeping a reference to the watch in an object cycle, making it only get closed if and when the garbage collector runs.
It's true that this isn't really an issue for most use cases, but it's not particularly responsible IMO to depend on destructors for resource cleanup. That's a C++ thing.
I find it a bit wonky that closing the watch can only be done through the destructor. Maybe it isn't the end of the world, but this sorta locks it to cPython.