[Python-Dev] Resource leaks warnings (original) (raw)

Steven D'Aprano steve at pearwood.info
Wed Sep 29 15:11:44 CEST 2010


On Wed, 29 Sep 2010 10:42:27 pm Antoine Pitrou wrote:

My assumption is/was that the benefit of warning against leaks in real applications (or even - sigh - the standard library) would outweigh the inconvenience when hacking together a quick script.

But if it doesn't, what about enabling it with a command-line switch?

I think the ability to detect such file descriptor leaks would be valuable, but I'm not sure that it should be running all the time. At the risk of bike-shedding, is it something which could be controlled at runtime, like garbage collection? E.g. something like:

gc.enable_file_warnings() run_my_tests_for_leakage() gc.disable_file_warnings()

or similar. (I'm not wedded to it being in the gc module.)

Otherwise, I'm +0.25 on enabling it with a command line switch, and -0 on turning it on by default.

-- Steven D'Aprano



More information about the Python-Dev mailing list