kennethreitz/requests — pull request #616 by slingamn (2012-05-15 23:59:16+00:00)
Title: draft pull request for eager release of sockets

Please do not merge this! This is intended as a "design review" :-) It needs more comments and tests before it is production ready.

This implements explicit disposal of sockets in urllib3 and Requests that does not rely on instantaneous garbage collection via reference counts (e.g., for PyPy). It should fix #520 without removing the `Response.request` member, or otherwise breaking the API (or the reference cycle, depending on whether you're a glass-half-full or glass-half-empty person).

It's split into three commits: one is a test case, one adds explicit disposal, one defaults `prefetch=True` and changes the tests to match.

@shazow maybe you could take a look at the urllib3 changes?

Thanks everyone.