[issue18144] FD leak in urllib2

Martin Panter report at bugs.python.org
Fri Dec 6 14:38:31 CET 2013


Martin Panter added the comment:

Confirmed that this happens when the server sends a chunked response, or sends a Content-Length header, but not when the server just sends “Connection: close”. So this looks like the same as Issue 19524, and my patch for that seems to fix the issue here.

Python 3 version of the demo code:

import os, urllib.request
data = b"""{"imp": [{"h": 50, "battr": ["9", "10", "12"], "api": 3, "w": 320,
"instl": 0, "impid": "5d6dedf3-17bb-11e2-b5c0-1040f38b83e0"}]""" * 10
req = urllib.request.Request("http://localhost:8000/bogus?src=1", data)
resp = urllib.request.urlopen(req)
v = resp.read()
resp.close()
os.system("ls -alh /proc/%d/fd/*" % os.getpid())

----------
nosy: +vadmium

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18144>
_______________________________________


More information about the Python-bugs-list mailing list