Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Run leakchecks on Python 3.7 #1197
We currently run these on CPython 2.7. The first time I tried to run them on Python 3 it was a mess. 3.7's cleanup of the way frame objects handle references should hopefully simplify things.
With luck we'll only need to tweak the rules in src/greentest/greentest/leakcheck.py to get a clean run.
And the results of 'make leaktest':
It's nice to see 5 tests that "leaked" on Python 2 don't on Python 3.7.
Of the failures, lots of the leaked refs are 'internal' python details: cell, method, function, getset_descriptor, builtin_function_or_method. Perhaps some of those need to be added to the excluded types in leakcheck.py, but it will take some study.
Lots of them are various exception classes (chaining?). Representative from test_socket_dns:
But there are clearly some substantial differences, especially when it comes to sockets or pywsgi. Representative pywsgi:
Yup, the bulk of the exception problems were chaining. We were raising a static exception object, and as the leaktests repeat over and over, the refs build up.
I've also dropped the bulk of our own refcounting code in favor of objgraph. The idea is that it will make debugging leaks easier (though so far I haven't really had to use that).
Switching to objgraph (and avoiding too many closures) also helped.