Sept. 2, 2024
4:02 p.m.
This is just my 2 cents as a PyPy user. CPython eagerly destroys unreferenced objects while PyPy will destroy them eventually. I ran into a problem with the requests library where it would create connection pool object every request, and the unreferenced pool would not be cleaned up immediately which caused the maximum number of open file descriptors to be reached (if I recall correctly). The solution to my case was calling `gc.collect_step()` (a PyPy-only function) after each request. You can also try the standard `gc.collect()` function which may be more reliable for a unit test to ensure any unreferenced objects are garbage collected. This may not help with the general use of your library though.